Fix NPE when querying EF Uri with non-existent subscription
Bug: 194910795
Test: atest TeleServiceTests:SimPhonebookProviderTest
Change-Id: Ic214b46600759e2c73a90bc50ef971d80303055d
diff --git a/src/com/android/phone/SimPhonebookProvider.java b/src/com/android/phone/SimPhonebookProvider.java
index b921398..5188d96 100644
--- a/src/com/android/phone/SimPhonebookProvider.java
+++ b/src/com/android/phone/SimPhonebookProvider.java
@@ -16,8 +16,8 @@
package com.android.phone;
-import static com.android.internal.telephony.IccProvider.STR_NEW_TAG;
import static com.android.internal.telephony.IccProvider.STR_NEW_NUMBER;
+import static com.android.internal.telephony.IccProvider.STR_NEW_TAG;
import android.Manifest;
import android.annotation.TestApi;
@@ -305,8 +305,10 @@
MatrixCursor result = new MatrixCursor(projection);
try {
- addEfToCursor(
- result, getActiveSubscriptionInfo(args.subscriptionId), args.efType);
+ SubscriptionInfo info = getActiveSubscriptionInfo(args.subscriptionId);
+ if (info != null) {
+ addEfToCursor(result, info, args.efType);
+ }
} catch (RemoteException e) {
// Return an empty cursor. If service to access it is throwing remote
// exceptions then it's basically the same as not having a SIM.
@@ -734,6 +736,7 @@
}
}
+ @Nullable
private SubscriptionInfo getActiveSubscriptionInfo(int subId) {
// Getting the SubscriptionInfo requires READ_PHONE_STATE.
CallingIdentity identity = clearCallingIdentity();