Loading src/java/com/android/internal/telephony/data/PhoneSwitcher.java +1 −1 Original line number Diff line number Diff line Loading @@ -1776,7 +1776,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; } Loading tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +33 −2 Original line number Diff line number Diff line Loading @@ -864,6 +864,37 @@ public class PhoneSwitcherTest extends TelephonyTest { assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId()); } @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 { Loading Loading @@ -1540,7 +1571,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(); Loading Loading @@ -2158,7 +2189,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(); if (defaultDataSub == 1) { Loading Loading
src/java/com/android/internal/telephony/data/PhoneSwitcher.java +1 −1 Original line number Diff line number Diff line Loading @@ -1776,7 +1776,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; } Loading
tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +33 −2 Original line number Diff line number Diff line Loading @@ -864,6 +864,37 @@ public class PhoneSwitcherTest extends TelephonyTest { assertEquals(1, mPhoneSwitcherUT.getActiveDataSubId()); } @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 { Loading Loading @@ -1540,7 +1571,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(); Loading Loading @@ -2158,7 +2189,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(); if (defaultDataSub == 1) { Loading