summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvinash Malipatil <avinashmp@google.com>2022-12-20 18:27:58 +0000
committerAvinash Malipatil <avinashmp@google.com>2023-01-13 04:44:35 +0000
commit901e86e07b5efe458a4b1e3921f6d2ff0a362771 (patch)
tree49c49f483b7073ad9076ec38332d196de3dd874d
parent2684834e705b29708ea4440db5a677f65e2ee4ed (diff)
downloadAlternativeNetworkAccess-901e86e07b5efe458a4b1e3921f6d2ff0a362771.tar.gz
Fetch all the subscriptions and handle null return.
Bug: 263143310 Test: atest ONSTests, System testing. Change-Id: Ib09b59ae861c74c5ac9bbc0073cb77c430af0735
-rw-r--r--src/com/android/ons/ONSProfileActivator.java7
-rw-r--r--src/com/android/ons/ONSProfileConfigurator.java12
-rw-r--r--tests/src/com/android/ons/ONSProfileActivatorTest.java17
3 files changed, 31 insertions, 5 deletions
diff --git a/src/com/android/ons/ONSProfileActivator.java b/src/com/android/ons/ONSProfileActivator.java
index 1c16c53..05228b8 100644
--- a/src/com/android/ons/ONSProfileActivator.java
+++ b/src/com/android/ons/ONSProfileActivator.java
@@ -173,12 +173,13 @@ public class ONSProfileActivator implements ONSProfileConfigurator.ONSProfConfig
//Check the number of active subscriptions.
List<SubscriptionInfo> activeSubInfos = mSubManager.getActiveSubscriptionInfoList();
+ if (activeSubInfos == null || activeSubInfos.size() <= 0) {
+ return Result.ERR_NO_SIM_INSERTED;
+ }
int activeSubCount = activeSubInfos.size();
Log.d(TAG, "Active subscription count:" + activeSubCount);
- if (activeSubCount <= 0) {
- return Result.ERR_NO_SIM_INSERTED;
- } else if (activeSubCount == 1) {
+ if (activeSubCount == 1) {
SubscriptionInfo pSubInfo = activeSubInfos.get(0);
if (pSubInfo.isOpportunistic()) {
//Only one SIM is active and its opportunistic SIM.
diff --git a/src/com/android/ons/ONSProfileConfigurator.java b/src/com/android/ons/ONSProfileConfigurator.java
index 11df97d..84bcdad 100644
--- a/src/com/android/ons/ONSProfileConfigurator.java
+++ b/src/com/android/ons/ONSProfileConfigurator.java
@@ -258,6 +258,10 @@ public class ONSProfileConfigurator {
//Get the list of active subscriptions
List<SubscriptionInfo> availSubInfoList = mSubscriptionManager
.getAvailableSubscriptionInfoList();
+ if (availSubInfoList == null) {
+ Log.e(TAG, "getAvailableSubscriptionInfoList returned null");
+ return null;
+ }
Log.d(TAG, "Available subscriptions: " + availSubInfoList.size());
//Get the list of opportunistic carrier-ids list from carrier config.
@@ -269,8 +273,12 @@ public class ONSProfileConfigurator {
return null;
}
- ParcelUuid pSIMSubGroupId = mSubscriptionManager.getActiveSubscriptionInfo(pSIMId)
- .getGroupUuid();
+ SubscriptionInfo subscriptionInfo = mSubscriptionManager.getActiveSubscriptionInfo(pSIMId);
+ if (subscriptionInfo == null) {
+ Log.e(TAG, "getActiveSubscriptionInfo returned null for: " + pSIMId);
+ return null;
+ }
+ ParcelUuid pSIMSubGroupId = subscriptionInfo.getGroupUuid();
for (SubscriptionInfo subInfo : availSubInfoList) {
if (subInfo.getSubscriptionId() != pSIMId) {
for (int carrId : oppCarrierIdArr) {
diff --git a/tests/src/com/android/ons/ONSProfileActivatorTest.java b/tests/src/com/android/ons/ONSProfileActivatorTest.java
index 3e94bd5..478f23a 100644
--- a/tests/src/com/android/ons/ONSProfileActivatorTest.java
+++ b/tests/src/com/android/ons/ONSProfileActivatorTest.java
@@ -251,6 +251,23 @@ public class ONSProfileActivatorTest extends ONSBaseTest {
onsProfileActivator.handleCarrierConfigChange());
}
+ public void testNullActiveSubscriptionList() {
+
+ doReturn(true).when(mMockResources).getBoolean(R.bool.enable_ons_auto_provisioning);
+ doReturn(true).when(mMockEuiccManager).isEnabled();
+ doReturn(2).when(mMockTeleManager).getSupportedModemCount();
+ doReturn(2).when(mMockTeleManager).getActiveModemCount();
+ doReturn(null).when(mMockSubManager).getActiveSubscriptionInfoList();
+
+ ONSProfileActivator onsProfileActivator = new ONSProfileActivator(mMockContext,
+ mMockSubManager, mMockTeleManager, mMockCarrierConfigManager, mMockEuiccManager,
+ mMockConnectivityManager, mMockONSProfileConfigurator, mMockONSProfileDownloader,
+ mMockONSStats);
+
+ assertEquals(ONSProfileActivator.Result.ERR_NO_SIM_INSERTED,
+ onsProfileActivator.handleCarrierConfigChange());
+ }
+
@Test
//@DisplayName("Dual SIM device and non CBRS carrier pSIM inserted")
public void testNonCBRSCarrierPSIMInserted() {