diff options
author | Ling Ma <linggm@google.com> | 2023-10-19 20:18:39 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-10-19 20:18:39 +0000 |
commit | 8cffe4bfdd4a1a4c19339b8d3c17cdcc96512144 (patch) | |
tree | 47515820957aa10eefdbb808fb388857198e643c | |
parent | b02408d6ba8e476522bb5fffdb0eadd3ac5d367d (diff) | |
parent | 2752add9c5d8a3fd4b2bf41b4ed2f378ff93c523 (diff) | |
download | telephony-8cffe4bfdd4a1a4c19339b8d3c17cdcc96512144.tar.gz |
Merge "Auto selected sub should never be actual default sub" into main am: 2752add9c5
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2796775
Change-Id: I54d48e333e29fe4d3cb518ee07fad8cba973d344
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/java/com/android/internal/telephony/data/PhoneSwitcher.java | 2 | ||||
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java | 35 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java index a5b3da25ab..cf1a47d3f6 100644 --- a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java +++ b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java @@ -1545,7 +1545,7 @@ public class PhoneSwitcher extends Handler { // If validation feature is not supported, set it directly. Otherwise, // start validation on the subscription first. if (!mValidator.isValidationFeatureSupported()) { - setAutoSelectedDataSubIdInternal(subIdToValidate); + setAutoSelectedDataSubIdInternal(subId); sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_SUCCESS); return; } diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java index 807f44c66b..c215483b63 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java @@ -679,6 +679,37 @@ public class PhoneSwitcherTest extends TelephonyTest { } @Test + public void testSetAutoSelectedValidationFeatureNotSupported() throws Exception { + doReturn(false).when(mCellularNetworkValidator).isValidationFeatureSupported(); + initialize(); + + // Phone 0 has sub 1, phone 1 has sub 2. + // Sub 1 is default data sub. + // Both are active subscriptions are active sub, as they are in both active slots. + setSlotIndexToSubId(0, 1); + setSlotIndexToSubId(1, 2); + setDefaultDataSubId(1); + + doReturn(new SubscriptionInfoInternal.Builder(mSubscriptionManagerService + .getSubscriptionInfoInternal(2)).setOpportunistic(1).build()) + .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2); + + mPhoneSwitcherUT.trySetOpportunisticDataSubscription(2, false, mSetOpptDataCallback1); + processAllMessages(); + mPhoneSwitcherUT.mValidationCallback.onNetworkAvailable(null, 2); + processAllMessages(); + assertEquals(2, mPhoneSwitcherUT.getAutoSelectedDataSubId()); + + // Switch to the default sub, verify AutoSelectedDataSubId is the default value. + clearInvocations(mSetOpptDataCallback1); + mPhoneSwitcherUT.trySetOpportunisticDataSubscription(SubscriptionManager + .DEFAULT_SUBSCRIPTION_ID, true, mSetOpptDataCallback1); + processAllMessages(); + assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, + mPhoneSwitcherUT.getAutoSelectedDataSubId()); + } + + @Test @SmallTest public void testSetPreferredDataModemCommand() throws Exception { doReturn(true).when(mMockRadioConfig).isSetPreferredDataCommandSupported(); @@ -1357,7 +1388,7 @@ public class PhoneSwitcherTest extends TelephonyTest { .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2); // Switch to primary before a primary is selected/inactive. - setDefaultDataSubId(-1); + setDefaultDataSubId(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mPhoneSwitcherUT.trySetOpportunisticDataSubscription( SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1); processAllMessages(); @@ -1991,7 +2022,7 @@ public class PhoneSwitcherTest extends TelephonyTest { doReturn(true).when(mDataConfigManager).isPingTestBeforeAutoDataSwitchRequired(); } - private void setDefaultDataSubId(int defaultDataSub) throws Exception { + private void setDefaultDataSubId(int defaultDataSub) { mDefaultDataSub = defaultDataSub; doReturn(mDefaultDataSub).when(mSubscriptionManagerService).getDefaultDataSubId(); for (Phone phone : mPhones) { |