diff options
| author | danielwbhuang <danielwbhuang@google.com> | 2019-10-29 20:29:50 +0800 |
|---|---|---|
| committer | danielwbhuang <danielwbhuang@google.com> | 2019-11-20 15:08:06 +0800 |
| commit | 0245be2ac2477fce4e904f5dbfeef720602091cf (patch) | |
| tree | 6f1b0822d8ec093fc3148deabc0ea276a5e65091 | |
| parent | b2325a85e540f07464fece792716b000992a7f3c (diff) | |
| download | platform_packages_services_AlternativeNetworkAccess-0245be2ac2477fce4e904f5dbfeef720602091cf.tar.gz platform_packages_services_AlternativeNetworkAccess-0245be2ac2477fce4e904f5dbfeef720602091cf.tar.bz2 platform_packages_services_AlternativeNetworkAccess-0245be2ac2477fce4e904f5dbfeef720602091cf.zip | |
Add more error codes for ONS.
1.Add error codes for setPreferredOpportunisticDataSubscription and updateAvailableNetworks
2.Modify ONSTests.
Test: atest ONSTests.
com.android.ons.tests (19 Tests)
[1/19] com.android.ons.ONSNetworkScanCtlrTest#testStartFastNetworkScan: PASSED (353ms)
[2/19] com.android.ons.ONSNetworkScanCtlrTest#testStartFastNetworkScanFail: PASSED (26ms)
[3/19] com.android.ons.ONSNetworkScanCtlrTest#testStartFastNetworkScanWithMultipleNetworks: PASSED (25ms)
[4/19] com.android.ons.ONSNetworkScanCtlrTest#testStopNetworkScan: PASSED (102ms)
[5/19] com.android.ons.ONSProfileSelectorTest#testStartProfileSelectionSuccess: PASSED (579ms)
[6/19] com.android.ons.ONSProfileSelectorTest#testStartProfileSelectionSuccessWithSameArgumentsAgain: PASSED (1.082s)
[7/19] com.android.ons.ONSProfileSelectorTest#testStartProfileSelectionWithActivePrimarySimOnESim: PASSED (5.182s)
[8/19] com.android.ons.ONSProfileSelectorTest#testStartProfileSelectionWithNoOpportunisticSub: PASSED (176ms)
[9/19] com.android.ons.ONSProfileSelectorTest#testselectProfileForDataWithInActiveSub: PASSED (25ms)
[10/19] com.android.ons.ONSProfileSelectorTest#testselectProfileForDataWithInvalidSubId: PASSED (227ms)
[11/19] com.android.ons.ONSProfileSelectorTest#testselectProfileForDataWithNoOpportunsticSub: PASSED (51ms)
[12/19] com.android.ons.ONSProfileSelectorTest#testselectProfileForDataWithValidSub: PASSED (51ms)
[13/19] com.android.ons.OpportunisticNetworkServiceTest#testGetPreferredDataSubscriptionId: PASSED (579ms)
[14/19] com.android.ons.OpportunisticNetworkServiceTest#testSetPreferredDataSubscriptionId: PASSED (25ms)
[15/19] com.android.ons.OpportunisticNetworkServiceTest#testSystemPreferredDataWhileCarrierAppIsActive: PASSED (76ms)
[16/19] com.android.ons.OpportunisticNetworkServiceTest#testCheckEnable: PASSED (26ms)
[17/19] com.android.ons.OpportunisticNetworkServiceTest#testHandleSimStateChange: PASSED (629ms)
[18/19] com.android.ons.OpportunisticNetworkServiceTest#testUpdateAvailableNetworksWithSuccess: PASSED (51ms)
[19/19] com.android.ons.OpportunisticNetworkServiceTest#testUpdateAvailableNetworksWithInvalidArguments: PASSED (25ms)
Bug: 130595455
Change-Id: I2bbdf3aab4562d3d465bc2ca6f86fdf2b1c50b1a
4 files changed, 49 insertions, 21 deletions
diff --git a/src/com/android/ons/ONSProfileSelector.java b/src/com/android/ons/ONSProfileSelector.java index 97c588b..ec0060c 100644 --- a/src/com/android/ons/ONSProfileSelector.java +++ b/src/com/android/ons/ONSProfileSelector.java @@ -140,8 +140,15 @@ public class ONSProfileSelector { handleNetworkScanResult(mAvailableNetworkInfos.get(0).getSubId()); } else { if (mNetworkScanCallback != null) { - sendUpdateNetworksCallbackHelper(mNetworkScanCallback, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + if (mIsEnabled) { + sendUpdateNetworksCallbackHelper(mNetworkScanCallback, + TelephonyManager + .UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + } else { + sendUpdateNetworksCallbackHelper(mNetworkScanCallback, + TelephonyManager + .UPDATE_AVAILABLE_NETWORKS_SERVICE_IS_DISABLED); + } mNetworkScanCallback = null; } } @@ -156,7 +163,7 @@ public class ONSProfileSelector { TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); } else { sendUpdateNetworksCallbackHelper(mNetworkScanCallback, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ABORTED); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ENABLE_MODEM_FAIL); } mProfileSelectionCallback.onProfileSelectionDone(); synchronized (mLock) { @@ -356,7 +363,7 @@ public class ONSProfileSelector { TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); } else { sendUpdateNetworksCallbackHelper(mNetworkScanCallback, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ABORTED); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ENABLE_MODEM_FAIL); } mProfileSelectionCallback.onProfileSelectionDone(); mNetworkScanCallback = null; @@ -455,7 +462,7 @@ public class ONSProfileSelector { if (mOppSubscriptionInfos == null) { logDebug("null subscription infos"); sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE); return; } @@ -503,7 +510,7 @@ public class ONSProfileSelector { TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); } else { sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ABORTED); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ENABLE_MODEM_FAIL); } mProfileSelectionCallback.onProfileSelectionDone(); mAvailableNetworkInfos = null; @@ -515,7 +522,7 @@ public class ONSProfileSelector { } } else if (mOppSubscriptionInfos.size() == 0) { sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE); /* check if no profile */ logDebug("stopping scan"); mNetworkScanCtlr.stopNetworkScan(); @@ -598,7 +605,7 @@ public class ONSProfileSelector { int subId = getActiveOpportunisticSubId(); if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE); return; } if (enableModem(subId, false)) { @@ -606,7 +613,7 @@ public class ONSProfileSelector { TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SUCCESS); } else { sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_ABORTED); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_DISABLE_MODEM_FAIL); } } @@ -686,6 +693,10 @@ public class ONSProfileSelector { IUpdateAvailableNetworksCallback callbackStub) { logDebug("startProfileSelection availableNetworks: " + availableNetworks); if (availableNetworks == null || availableNetworks.size() == 0) { + if (callbackStub != null) { + sendUpdateNetworksCallbackHelper(callbackStub, + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + } return; } Object[] objects = new Object[]{availableNetworks, callbackStub}; @@ -715,7 +726,7 @@ public class ONSProfileSelector { if (iSub == null) { log("Could not get Subscription Service handle"); sendSetOpptCallbackHelper(callbackStub, - TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED); + TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); return; } try { @@ -723,14 +734,19 @@ public class ONSProfileSelector { } catch (RemoteException ex) { log("Could not connect to Subscription Service"); sendSetOpptCallbackHelper(callbackStub, - TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED); + TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); return; } mCurrentDataSubId = subId; } else { log("Inactive sub passed for preferred data " + subId); - sendSetOpptCallbackHelper(callbackStub, - TelephonyManager.SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); + if (isOpprotunisticSub(subId)) { + sendSetOpptCallbackHelper(callbackStub, + TelephonyManager.SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); + } else { + sendSetOpptCallbackHelper(callbackStub, + TelephonyManager.SET_OPPORTUNISTIC_SUB_NO_OPPORTUNISTIC_SUB_AVAILABLE); + } } } diff --git a/src/com/android/ons/OpportunisticNetworkService.java b/src/com/android/ons/OpportunisticNetworkService.java index 6db5fa8..b832a47 100644 --- a/src/com/android/ons/OpportunisticNetworkService.java +++ b/src/com/android/ons/OpportunisticNetworkService.java @@ -381,14 +381,14 @@ public class OpportunisticNetworkService extends Service { if (availableNetworks.size() > 1) { log("Carrier app should not pass more than one subscription"); sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_MULTIPLE_NETWORKS_NOT_SUPPORTED); return; } if (!mProfileSelector.hasOpprotunisticSub(availableNetworks)) { log("No opportunistic subscriptions received"); sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE); return; } @@ -421,6 +421,9 @@ public class OpportunisticNetworkService extends Service { if (mIsEnabled) { /* if carrier is reporting availability, then it takes higher priority. */ mProfileSelector.startProfileSelection(availableNetworks, callbackStub); + } else { + sendUpdateNetworksCallbackHelper(callbackStub, + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SERVICE_IS_DISABLED); } } finally { Binder.restoreCallingIdentity(identity); @@ -481,15 +484,21 @@ public class OpportunisticNetworkService extends Service { if (!mProfileSelector.hasOpprotunisticSub(availableNetworks)) { log("No opportunistic subscriptions received"); sendUpdateNetworksCallbackHelper(callbackStub, - TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS); + TelephonyManager + .UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE); return; } mONSConfigInputHashMap.put(SYSTEM_APP_CONFIG_NAME, new ONSConfigInput(availableNetworks, callbackStub)); /* reporting availability. proceed if carrier app has not requested any */ - if (mIsEnabled && mONSConfigInputHashMap.get(CARRIER_APP_CONFIG_NAME) == null) { - mProfileSelector.startProfileSelection(availableNetworks, callbackStub); + if (mIsEnabled) { + if (mONSConfigInputHashMap.get(CARRIER_APP_CONFIG_NAME) == null) { + mProfileSelector.startProfileSelection(availableNetworks, callbackStub); + } + } else { + sendUpdateNetworksCallbackHelper(callbackStub, + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_SERVICE_IS_DISABLED); } } else { if (!mIsEnabled) { diff --git a/tests/src/com/android/ons/ONSProfileSelectorTest.java b/tests/src/com/android/ons/ONSProfileSelectorTest.java index a3b5a72..86cf826 100644 --- a/tests/src/com/android/ons/ONSProfileSelectorTest.java +++ b/tests/src/com/android/ons/ONSProfileSelectorTest.java @@ -161,7 +161,8 @@ public class ONSProfileSelectorTest extends ONSBaseTest { // Testing startProfileSelection without any oppotunistic data. // should not get any callback invocation. waitUntilReady(100); - assertEquals(TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS, mResult); + assertEquals( + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE, mResult); assertFalse(mCallbackInvoked); } diff --git a/tests/src/com/android/ons/OpportunisticNetworkServiceTest.java b/tests/src/com/android/ons/OpportunisticNetworkServiceTest.java index ae28862..74330b4 100644 --- a/tests/src/com/android/ons/OpportunisticNetworkServiceTest.java +++ b/tests/src/com/android/ons/OpportunisticNetworkServiceTest.java @@ -217,7 +217,8 @@ public class OpportunisticNetworkServiceTest extends ONSBaseTest { } catch (RemoteException ex) { Log.e(TAG, "RemoteException", ex); } - assertEquals(TelephonyManager.SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION, mResult); + assertEquals( + TelephonyManager.SET_OPPORTUNISTIC_SUB_NO_OPPORTUNISTIC_SUB_AVAILABLE, mResult); } @Test @@ -257,7 +258,8 @@ public class OpportunisticNetworkServiceTest extends ONSBaseTest { } catch (RemoteException ex) { Log.e(TAG, "RemoteException", ex); } - assertEquals(TelephonyManager.UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS, mResult); + assertEquals( + TelephonyManager.UPDATE_AVAILABLE_NETWORKS_NO_OPPORTUNISTIC_SUB_AVAILABLE, mResult); } @Test |
