Merge "Fixed allocate/deallocate PDU session id" into sc-qpr1-dev
diff --git a/src/java/com/android/internal/telephony/CarrierResolver.java b/src/java/com/android/internal/telephony/CarrierResolver.java
index 794bb41..c1e1136 100644
--- a/src/java/com/android/internal/telephony/CarrierResolver.java
+++ b/src/java/com/android/internal/telephony/CarrierResolver.java
@@ -27,6 +27,7 @@
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
+import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
import android.provider.Telephony;
@@ -164,7 +165,7 @@
updateCarrierIdAndName(
carrierId, carrierName != null ? carrierName : "",
specificCarrierId, specificCarrierName != null ? carrierName : "",
- mnoCarrierId);
+ mnoCarrierId, false);
}
}
};
@@ -215,12 +216,12 @@
handleSimAbsent();
break;
case IccCardConstants.INTENT_VALUE_ICC_LOADED:
- handleSimLoaded();
+ handleSimLoaded(false);
break;
}
}
- private void handleSimLoaded() {
+ private void handleSimLoaded(boolean isSimOverride) {
if (mIccRecords != null) {
/**
* returns empty string to be consistent with
@@ -232,7 +233,9 @@
loge("mIccRecords is null on SIM_LOAD_EVENT, could not get SPN");
}
mPreferApn = getPreferApn();
- loadCarrierMatchingRulesOnMccMnc(false /* update carrier config */);
+ loadCarrierMatchingRulesOnMccMnc(
+ false /* update carrier config */,
+ isSimOverride);
}
private void handleSimAbsent() {
@@ -241,7 +244,7 @@
mPreferApn = null;
updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null,
TelephonyManager.UNKNOWN_CARRIER_ID, null,
- TelephonyManager.UNKNOWN_CARRIER_ID);
+ TelephonyManager.UNKNOWN_CARRIER_ID, false);
}
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@@ -274,19 +277,24 @@
if (DBG) logd("handleMessage: " + msg.what);
switch (msg.what) {
case SIM_LOAD_EVENT:
- handleSimLoaded();
+ AsyncResult result = (AsyncResult) msg.obj;
+ boolean isSimOverride = false;
+ if (result != null) {
+ isSimOverride = result.userObj instanceof Boolean && (Boolean) result.userObj;
+ }
+ handleSimLoaded(isSimOverride);
break;
case CARRIER_ID_DB_UPDATE_EVENT:
// clean the cached carrier list version, so that a new one will be queried.
mCarrierListVersion = null;
- loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/);
+ loadCarrierMatchingRulesOnMccMnc(true /* update carrier config*/, false);
break;
case PREFER_APN_UPDATE_EVENT:
String preferApn = getPreferApn();
if (!equals(mPreferApn, preferApn, true)) {
logd("[updatePreferApn] from:" + mPreferApn + " to:" + preferApn);
mPreferApn = preferApn;
- matchSubscriptionCarrier(true /* update carrier config*/);
+ matchSubscriptionCarrier(true /* update carrier config*/, false);
}
break;
case ICC_CHANGED_EVENT:
@@ -301,7 +309,8 @@
}
if (newIccRecords != null) {
logd("new Icc object");
- newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, null);
+ newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT,
+ /* is sim override*/true);
mIccRecords = newIccRecords;
}
}
@@ -312,7 +321,9 @@
}
}
- private void loadCarrierMatchingRulesOnMccMnc(boolean updateCarrierConfig) {
+ private void loadCarrierMatchingRulesOnMccMnc(
+ boolean updateCarrierConfig,
+ boolean isSimOverride) {
try {
String mccmnc = mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId());
Cursor cursor = mContext.getContentResolver().query(
@@ -330,7 +341,7 @@
while (cursor.moveToNext()) {
mCarrierMatchingRulesOnMccMnc.add(makeCarrierMatchingRule(cursor));
}
- matchSubscriptionCarrier(updateCarrierConfig);
+ matchSubscriptionCarrier(updateCarrierConfig, isSimOverride);
// Generate metrics related to carrier ID table version.
CarrierIdMatchStats.sendCarrierIdTableVersion(getCarrierListVersion());
@@ -465,7 +476,7 @@
private void updateCarrierIdAndName(int cid, String name,
int specificCarrierId, String specificCarrierName,
- int mnoCid) {
+ int mnoCid, boolean isSimOverride) {
boolean update = false;
if (specificCarrierId != mSpecificCarrierId) {
logd("[updateSpecificCarrierId] from:" + mSpecificCarrierId + " to:"
@@ -534,7 +545,7 @@
// during esim profile switch, there is no sim absent thus carrier id will persist and
// might not trigger an update if switch profiles for the same carrier. thus always update
// subscriptioninfo db to make sure we have correct carrier id set.
- if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) {
+ if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId()) && !isSimOverride) {
// only persist carrier id to simInfo db when subId is valid.
SubscriptionController.getInstance().setCarrierId(mCarrierId, mPhone.getSubId());
}
@@ -827,7 +838,7 @@
/**
* find the best matching carrier from candidates with matched subscription MCCMNC.
*/
- private void matchSubscriptionCarrier(boolean updateCarrierConfig) {
+ private void matchSubscriptionCarrier(boolean updateCarrierConfig, boolean isSimOverride) {
if (!SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) {
logd("[matchSubscriptionCarrier]" + "skip before sim records loaded");
return;
@@ -870,7 +881,7 @@
+ " name: " + null);
updateCarrierIdAndName(TelephonyManager.UNKNOWN_CARRIER_ID, null,
TelephonyManager.UNKNOWN_CARRIER_ID, null,
- TelephonyManager.UNKNOWN_CARRIER_ID);
+ TelephonyManager.UNKNOWN_CARRIER_ID, isSimOverride);
} else {
// if there is a single matching result, check if this rule has parent cid assigned.
if ((maxRule == maxRuleParent)
@@ -884,7 +895,7 @@
+ " name: " + maxRuleParent.mName);
updateCarrierIdAndName(maxRuleParent.mCid, maxRuleParent.mName,
maxRule.mCid, maxRule.mName,
- (mnoRule == null) ? maxRule.mCid : mnoRule.mCid);
+ (mnoRule == null) ? maxRule.mCid : mnoRule.mCid, isSimOverride);
if (updateCarrierConfig) {
logd("[matchSubscriptionCarrier] - Calling updateCarrierConfig()");
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index ef55abb..bdc364d 100755
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -3181,6 +3181,12 @@
mRadioPowerLog.log(tmpLog);
}
+ if (mDesiredPowerState && mDeviceShuttingDown) {
+ log("setPowerStateToDesired powering on of radio failed because the device is " +
+ "powering off");
+ return;
+ }
+
// If we want it on and it's off, turn it on
if (mDesiredPowerState && !mRadioDisabledByCarrier
&& (forceApply || mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF)) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DataThrottler.java b/src/java/com/android/internal/telephony/dataconnection/DataThrottler.java
index 47b7d20..4a465d2 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DataThrottler.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DataThrottler.java
@@ -192,9 +192,18 @@
List<ThrottleStatus> changedStatuses = new ArrayList<>();
while (apnTypes != 0) {
-
- //Extract the least significant bit.
- int apnType = apnTypes & -apnTypes;
+ int apnType;
+ // Due to an API mistake of ApnSetting.TYPE_DEFAULT (which combines default and hipri
+ // bit), we need to do special handling here.
+ if ((apnTypes & ApnSetting.TYPE_DEFAULT) == ApnSetting.TYPE_DEFAULT) {
+ apnType = ApnSetting.TYPE_DEFAULT;
+ apnTypes &= ~ApnSetting.TYPE_DEFAULT;
+ } else {
+ //Extract the least significant bit.
+ apnType = apnTypes & -apnTypes;
+ //Remove the least significant bit.
+ apnTypes &= apnTypes - 1;
+ }
//Update the apn throttle status
ThrottleStatus newStatus = createStatus(apnType, retryElapsedTime, newRequestType);
@@ -209,9 +218,6 @@
//Put the new status in the temp space
mThrottleStatus.put(apnType, newStatus);
}
-
- //Remove the least significant bit.
- apnTypes &= apnTypes - 1;
}
if (changedStatuses.size() > 0) {
@@ -232,12 +238,6 @@
*/
@ElapsedRealtimeLong
public long getRetryTime(@ApnType int apnType) {
- // This is the workaround to handle the mistake that
- // ApnSetting.TYPE_DEFAULT = ApnTypes.DEFAULT | ApnTypes.HIPRI.
- if (apnType == ApnSetting.TYPE_DEFAULT) {
- apnType &= ~(ApnSetting.TYPE_HIPRI);
- }
-
ThrottleStatus status = mThrottleStatus.get(apnType);
if (status != null) {
if (status.getThrottleType() == ThrottleStatus.THROTTLE_TYPE_NONE) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
index 2db2706..21b8c4f 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -94,6 +94,7 @@
import android.telephony.data.DataCallResponse;
import android.telephony.data.DataCallResponse.HandoverFailureMode;
import android.telephony.data.DataProfile;
+import android.telephony.data.ThrottleStatus;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.EventLog;
@@ -446,6 +447,19 @@
}
};
+ private class ThrottleStatusChangedCallback implements DataThrottler.Callback {
+ @Override
+ public void onThrottleStatusChanged(List<ThrottleStatus> throttleStatuses) {
+ for (ThrottleStatus status : throttleStatuses) {
+ if (status.getThrottleType() == ThrottleStatus.THROTTLE_TYPE_NONE) {
+ setupDataOnConnectableApn(mApnContextsByType.get(status.getApnType()),
+ Phone.REASON_DATA_UNTHROTTLED,
+ RetryFailures.ALWAYS);
+ }
+ }
+ }
+ }
+
private NetworkPolicyManager mNetworkPolicyManager;
private final NetworkPolicyManager.SubscriptionCallback mSubscriptionCallback =
new NetworkPolicyManager.SubscriptionCallback() {
@@ -717,6 +731,8 @@
private final DataThrottler mDataThrottler;
+ private final ThrottleStatusChangedCallback mThrottleStatusCallback;
+
/**
* Request network completion message map. Key is the APN type, value is the list of completion
* messages to be sent. Using a list because there might be multiple network requests for
@@ -792,6 +808,9 @@
mSettingsObserver = new SettingsObserver(mPhone.getContext(), this);
registerSettingsObserver();
+
+ mThrottleStatusCallback = new ThrottleStatusChangedCallback();
+ mDataThrottler.registerForThrottleStatusChanges(mThrottleStatusCallback);
}
@VisibleForTesting
@@ -806,6 +825,7 @@
mTransportType = 0;
mDataServiceManager = null;
mDataThrottler = null;
+ mThrottleStatusCallback = null;
}
public void registerServiceStateTrackerEvents() {
@@ -2569,9 +2589,6 @@
@ApnType int apnTypes = apnSetting.getApnTypeBitmask();
mDataThrottler.setRetryTime(apnTypes, RetryManager.NO_SUGGESTED_RETRY_DELAY,
REQUEST_TYPE_NORMAL);
- // After data unthrottled, we should see if it's possible to bring up the data
- // again.
- setupDataOnAllConnectableApns(Phone.REASON_DATA_UNTHROTTLED, RetryFailures.ALWAYS);
} else {
loge("EVENT_APN_UNTHROTTLED: Invalid APN passed: " + apn);
}
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index f67082a..c6818e3 100755
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -1857,7 +1857,7 @@
callToHold.hold();
mMetrics.writeOnImsCommand(mPhone.getPhoneId(), callToHold.getSession(),
ImsCommand.IMS_CMD_HOLD);
- } catch (ImsException e) {
+ } catch (ImsException | NullPointerException e) {
mForegroundCall.switchWith(mBackgroundCall);
mHoldSwitchingState = oldHoldState;
logHoldSwapState("holdActiveCall - fail");
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java b/tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java
index 9c29eda..aa11743 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SignalStrengthUpdateRequestTest.java
@@ -34,36 +34,59 @@
public class SignalStrengthUpdateRequestTest extends TestCase {
- private SignalThresholdInfo mRssiInfo = new SignalThresholdInfo.Builder()
+ private SignalThresholdInfo mRssiInfoOnGERAN = new SignalThresholdInfo.Builder()
.setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
.setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
.setThresholds(new int[]{-109, -103, -97, -89})
.build();
- private SignalThresholdInfo mRscpInfo = new SignalThresholdInfo.Builder()
+ private SignalThresholdInfo mRssiInfoOnGERAN2 = new SignalThresholdInfo.Builder()
+ .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.GERAN)
+ .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
+ .setThresholds(new int[]{-108, -102, -96, -88})
+ .build();
+
+ private SignalThresholdInfo mRssiInfoOnCDMA2000 = new SignalThresholdInfo.Builder()
+ .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.CDMA2000)
+ .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSSI)
+ .setThresholds(new int[]{-109, -103, -97, -89})
+ .build();
+
+ private SignalThresholdInfo mRscpInfoOnUTRAN = new SignalThresholdInfo.Builder()
.setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.UTRAN)
.setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSCP)
.setThresholds(new int[]{-115, -105, -95, -85})
.build();
+ private SignalThresholdInfo mRsrpInfoOnEUTRAN = new SignalThresholdInfo.Builder()
+ .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
+ .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRP)
+ .setThresholds(new int[]{-115, -105, -95, -85})
+ .build();
+
+ private SignalThresholdInfo mRsrqInfoEUTRAN = new SignalThresholdInfo.Builder()
+ .setRadioAccessNetworkType(AccessNetworkConstants.AccessNetworkType.EUTRAN)
+ .setSignalMeasurementType(SignalThresholdInfo.SIGNAL_MEASUREMENT_TYPE_RSRQ)
+ .setThresholds(new int[]{-30, -20, -10, -1})
+ .build();
+
@Test
@SmallTest
public void testPublicConstructorWithInvalidParam() {
// null Collection
validateBuilderWithInvalidParam(null);
- // duplication of SignalMeasurementType in Collection
- validateBuilderWithInvalidParam(List.of(mRssiInfo, mRssiInfo));
+ // duplication of SignalMeasurementType for the same RAN in Collection
+ validateBuilderWithInvalidParam(List.of(mRssiInfoOnGERAN, mRssiInfoOnGERAN2));
- // The following two cases can not turn on until the implement is ready:
// empty Collections
- // validateBuilderWithInvalidParam(List.of());
+ validateBuilderWithInvalidParam(List.of());
}
@Test
@SmallTest
public void testPublicConstructorWithValidParam() {
- Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo);
+ Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN);
SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder()
.setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(false).build();
assertFalse(request.isReportingRequestedWhileIdle());
@@ -74,7 +97,7 @@
@Test
@SmallTest
public void testParcel() {
- Collection<SignalThresholdInfo> infos = List.of(mRssiInfo, mRscpInfo);
+ Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRscpInfoOnUTRAN);
SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder()
.setSignalThresholdInfos(infos).setReportingRequestedWhileIdle(true).build();
@@ -90,14 +113,14 @@
@Test
@SmallTest
public void testEquals() {
- Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfo, mRscpInfo);
+ Collection<SignalThresholdInfo> infos1 = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000);
SignalStrengthUpdateRequest request1 = new SignalStrengthUpdateRequest.Builder()
.setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false).build();
assertTrue(request1.equals(request1));
// Ordering does not matter
- Collection<SignalThresholdInfo> infos2 = List.of(mRscpInfo, mRssiInfo);
+ Collection<SignalThresholdInfo> infos2 = List.of(mRssiInfoOnCDMA2000, mRssiInfoOnGERAN);
SignalStrengthUpdateRequest request2 = new SignalStrengthUpdateRequest.Builder()
.setSignalThresholdInfos(infos2).setReportingRequestedWhileIdle(false).build();
assertTrue(request1.equals(request2));
@@ -109,11 +132,36 @@
SignalStrengthUpdateRequest request4 = new SignalStrengthUpdateRequest.Builder()
.setSignalThresholdInfos(infos1).setReportingRequestedWhileIdle(false)
.setSystemThresholdReportingRequestedWhileIdle(true).build();
+ assertFalse(request1.equals(request4));
// return false if the object is not SignalStrengthUpdateRequest
assertFalse(request1.equals("test"));
}
+ @Test
+ @SmallTest
+ public void testMultipleSignalMeasurementTypeOnSameRan() {
+ Collection<SignalThresholdInfo> infos = List.of(mRsrpInfoOnEUTRAN, mRsrqInfoEUTRAN);
+ SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder()
+ .setSignalThresholdInfos(infos).build();
+
+ assertFalse(request.isReportingRequestedWhileIdle());
+ assertFalse(request.isSystemThresholdReportingRequestedWhileIdle());
+ assertEquals(infos, request.getSignalThresholdInfos());
+ }
+
+ @Test
+ @SmallTest
+ public void testSameSignalMeasurementTypeOnDifferentRan() {
+ Collection<SignalThresholdInfo> infos = List.of(mRssiInfoOnGERAN, mRssiInfoOnCDMA2000);
+ SignalStrengthUpdateRequest request = new SignalStrengthUpdateRequest.Builder()
+ .setSignalThresholdInfos(infos).build();
+
+ assertFalse(request.isReportingRequestedWhileIdle());
+ assertFalse(request.isSystemThresholdReportingRequestedWhileIdle());
+ assertEquals(infos, request.getSignalThresholdInfos());
+ }
+
private void validateBuilderWithInvalidParam(Collection<SignalThresholdInfo> infos) {
try {
new SignalStrengthUpdateRequest.Builder()
diff --git a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataThrottlerTest.java b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataThrottlerTest.java
index fb9a8b6..9a8c4c8 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataThrottlerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataThrottlerTest.java
@@ -60,8 +60,6 @@
@Mock
private DataThrottler.Callback mMockChangedCallback2;
- private static final int DEFAULT_APN_TYPE = ApnSetting.TYPE_DEFAULT & ~(ApnSetting.TYPE_HIPRI);
-
@Before
public void setUp() throws Exception {
super.setUp(getClass().getSimpleName());
@@ -97,16 +95,9 @@
processAllMessages();
expectedStatuses.add(List.of(
new ThrottleStatus.Builder()
- .setSlotIndex(0)
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
- .setApnType(ApnSetting.TYPE_HIPRI)
- .setThrottleExpiryTimeMillis(1234567890L)
- .setRetryType(ThrottleStatus.RETRY_TYPE_NEW_CONNECTION)
- .build(),
- new ThrottleStatus.Builder()
.setSlotIndex(0)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
- .setApnType(DEFAULT_APN_TYPE)
+ .setApnType(ApnSetting.TYPE_DEFAULT)
.setThrottleExpiryTimeMillis(1234567890L)
.setRetryType(ThrottleStatus.RETRY_TYPE_NEW_CONNECTION)
.build())
@@ -124,13 +115,6 @@
new ThrottleStatus.Builder()
.setSlotIndex(0)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
- .setApnType(ApnSetting.TYPE_HIPRI)
- .setThrottleExpiryTimeMillis(13579L)
- .setRetryType(ThrottleStatus.RETRY_TYPE_HANDOVER)
- .build(),
- new ThrottleStatus.Builder()
- .setSlotIndex(0)
- .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
.setApnType(ApnSetting.TYPE_DUN)
.setThrottleExpiryTimeMillis(13579L)
.setRetryType(ThrottleStatus.RETRY_TYPE_HANDOVER)
@@ -138,7 +122,7 @@
new ThrottleStatus.Builder()
.setSlotIndex(0)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
- .setApnType(DEFAULT_APN_TYPE)
+ .setApnType(ApnSetting.TYPE_DEFAULT)
.setThrottleExpiryTimeMillis(13579L)
.setRetryType(ThrottleStatus.RETRY_TYPE_HANDOVER)
.build())