diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2019-12-07 02:05:38 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-12-07 02:05:38 +0000 |
| commit | d04c1b3428c3294f1b50f5b493f8197f1cf182c4 (patch) | |
| tree | ecd34cd20eda45080dd0e50c7efba958bab10500 | |
| parent | df16ec93c00aa9b1902e3d26a19e548fbf2c105d (diff) | |
| parent | 4b19d8f2edb4c97ac5d0966275db3001adc0167e (diff) | |
| download | platform_packages_services_AlternativeNetworkAccess-android10-qpr2-release.tar.gz platform_packages_services_AlternativeNetworkAccess-android10-qpr2-release.tar.bz2 platform_packages_services_AlternativeNetworkAccess-android10-qpr2-release.zip | |
Snap for 6055731 from 4b19d8f2edb4c97ac5d0966275db3001adc0167e to qt-qpr2-releaseandroid-10.0.0_r36android-10.0.0_r35android-10.0.0_r34android-10.0.0_r33android-10.0.0_r32android-10.0.0_r31android-10.0.0_r30android10-qpr2-s4-releaseandroid10-qpr2-s3-releaseandroid10-qpr2-s2-releaseandroid10-qpr2-s1-releaseandroid10-qpr2-release
Change-Id: Ic150d082b3024a7ddc9e72e311bac24010b0a169
| -rw-r--r-- | src/com/android/ons/ONSProfileSelector.java | 9 | ||||
| -rw-r--r-- | tests/src/com/android/ons/ONSProfileSelectorTest.java | 105 |
2 files changed, 113 insertions, 1 deletions
diff --git a/src/com/android/ons/ONSProfileSelector.java b/src/com/android/ons/ONSProfileSelector.java index 4bf38b9..83c4883 100644 --- a/src/com/android/ons/ONSProfileSelector.java +++ b/src/com/android/ons/ONSProfileSelector.java @@ -97,7 +97,8 @@ public class ONSProfileSelector { private ONSProfileSelectionCallback mProfileSelectionCallback; private int mSequenceId; private int mSubId; - private int mCurrentDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + @VisibleForTesting + protected int mCurrentDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private ArrayList<AvailableNetworkInfo> mAvailableNetworkInfos; private IUpdateAvailableNetworksCallback mNetworkScanCallback; @@ -615,6 +616,12 @@ public class ONSProfileSelector { return false; } + // If disabling modem for opportunistic sub, make sure to switch data back to default sub. + if (!enable) { + if (mSubscriptionManager.getPreferredDataSubscriptionId() == subId) { + selectProfileForData(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, null); + } + } int phoneId = SubscriptionManager.getPhoneId(subId); /* Todo: b/135067156 * Reenable this code once 135067156 is fixed diff --git a/tests/src/com/android/ons/ONSProfileSelectorTest.java b/tests/src/com/android/ons/ONSProfileSelectorTest.java index a3b5a72..253971f 100644 --- a/tests/src/com/android/ons/ONSProfileSelectorTest.java +++ b/tests/src/com/android/ons/ONSProfileSelectorTest.java @@ -82,6 +82,14 @@ public class ONSProfileSelectorTest extends ONSBaseTest { updateOpportunisticSubscriptions(); } + public int getCurrentPreferredData() { + return mCurrentDataSubId; + } + + public void setCurrentPreferredData(int subId) { + mCurrentDataSubId = subId; + } + protected void init(Context c, MyONSProfileSelector.ONSProfileSelectionCallback aNSProfileSelectionCallback) { super.init(c, aNSProfileSelectionCallback); @@ -543,4 +551,101 @@ public class ONSProfileSelectorTest extends ONSBaseTest { assertEquals(TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS, mResult); assertTrue(mReady); } + + @Test + public void testStopProfileSelectionWithPreferredDataOnSame() { + List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>(); + SubscriptionInfo subscriptionInfo = new SubscriptionInfo(5, "", 1, "TMO", "TMO", 1, 1, + "123", 1, null, "310", "210", "", true, null, "1", true, null, 0, 0); + subscriptionInfoList.add(subscriptionInfo); + + IUpdateAvailableNetworksCallback mCallback = new IUpdateAvailableNetworksCallback.Stub() { + @Override + public void onComplete(int result) { + mResult = result; + } + }; + + mResult = -1; + mReady = false; + new Thread(new Runnable() { + @Override + public void run() { + Looper.prepare(); + doReturn(subscriptionInfoList).when(mSubscriptionManager) + .getOpportunisticSubscriptions(); + doReturn(true).when(mSubscriptionManager).isActiveSubId(anyInt()); + doReturn(true).when(mSubscriptionBoundTelephonyManager).enableModemForSlot( + anyInt(), anyBoolean()); + doReturn(5).when(mSubscriptionManager).getPreferredDataSubscriptionId(); + doReturn(subscriptionInfoList).when(mSubscriptionManager) + .getActiveSubscriptionInfoList(anyBoolean()); + + mONSProfileSelector = new MyONSProfileSelector(mContext, + new MyONSProfileSelector.ONSProfileSelectionCallback() { + public void onProfileSelectionDone() { + setReady(true); + } + }); + mONSProfileSelector.updateOppSubs(); + mONSProfileSelector.setCurrentPreferredData(5); + mONSProfileSelector.stopProfileSelection(null); + mLooper = Looper.myLooper(); + setReady(true); + Looper.loop(); + } + }).start(); + waitUntilReady(); + waitForMs(500); + assertEquals(mONSProfileSelector.getCurrentPreferredData(), SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); + } + + @Test + public void testStopProfileSelectionWithPreferredDataOnDifferent() { + List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>(); + SubscriptionInfo subscriptionInfo = new SubscriptionInfo(5, "", 1, "TMO", "TMO", 1, 1, + "123", 1, null, "310", "210", "", true, null, "1", true, null, 0, 0); + subscriptionInfoList.add(subscriptionInfo); + + IUpdateAvailableNetworksCallback mCallback = new IUpdateAvailableNetworksCallback.Stub() { + @Override + public void onComplete(int result) { + mResult = result; + } + }; + + mResult = -1; + mReady = false; + new Thread(new Runnable() { + @Override + public void run() { + Looper.prepare(); + doReturn(subscriptionInfoList).when(mSubscriptionManager) + .getOpportunisticSubscriptions(); + doReturn(true).when(mSubscriptionManager).isActiveSubId(anyInt()); + doReturn(true).when(mSubscriptionBoundTelephonyManager).enableModemForSlot( + anyInt(), anyBoolean()); + doReturn(4).when(mSubscriptionManager).getPreferredDataSubscriptionId(); + doReturn(subscriptionInfoList).when(mSubscriptionManager) + .getActiveSubscriptionInfoList(anyBoolean()); + + mONSProfileSelector = new MyONSProfileSelector(mContext, + new MyONSProfileSelector.ONSProfileSelectionCallback() { + public void onProfileSelectionDone() { + setReady(true); + } + }); + mONSProfileSelector.updateOppSubs(); + mONSProfileSelector.setCurrentPreferredData(5); + mONSProfileSelector.stopProfileSelection(null); + mLooper = Looper.myLooper(); + setReady(true); + Looper.loop(); + } + }).start(); + waitUntilReady(); + waitForMs(500); + assertEquals(mONSProfileSelector.getCurrentPreferredData(), 5); + } + } |
