diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-04 01:26:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-04 01:26:27 +0000 |
commit | 2e17d1077a70cea47f9c59833a62605155500cb0 (patch) | |
tree | baa56576735b98e4a6167c1c9b13018e4d3061bb | |
parent | cd039062f442c06e2d58025801f61fbb71836bfa (diff) | |
parent | 529cd5265bd8b0c468f3fcb8f46b9756b5d3350e (diff) | |
download | ContactsProvider-android-security-13.0.0_r15.tar.gz |
Snap for 8681172 from 529cd5265bd8b0c468f3fcb8f46b9756b5d3350e to tm-releaseandroid-vts-13.0_r8android-vts-13.0_r7android-vts-13.0_r6android-vts-13.0_r5android-vts-13.0_r4android-vts-13.0_r3android-vts-13.0_r2android-vts-13.0_r1android-security-13.0.0_r9android-security-13.0.0_r8android-security-13.0.0_r7android-security-13.0.0_r6android-security-13.0.0_r5android-security-13.0.0_r4android-security-13.0.0_r3android-security-13.0.0_r2android-security-13.0.0_r17android-security-13.0.0_r16android-security-13.0.0_r15android-security-13.0.0_r14android-security-13.0.0_r13android-security-13.0.0_r12android-security-13.0.0_r11android-security-13.0.0_r10android-security-13.0.0_r1android-platform-13.0.0_r2android-platform-13.0.0_r1android-cts-13.0_r8android-cts-13.0_r7android-cts-13.0_r6android-cts-13.0_r5android-cts-13.0_r4android-cts-13.0_r3android-cts-13.0_r2android-cts-13.0_r1android-13.0.0_r8android-13.0.0_r7android-13.0.0_r6android-13.0.0_r5android-13.0.0_r4android-13.0.0_r31android-13.0.0_r3android-13.0.0_r2android-13.0.0_r12android-13.0.0_r1android13-tests-releaseandroid13-security-releaseandroid13-s3-releaseandroid13-s2-releaseandroid13-s1-releaseandroid13-release
Change-Id: I0ea34fc54cc0cf20a2e53d6e8e64b7584f127325
-rw-r--r-- | src/com/android/providers/contacts/CallLogProvider.java | 8 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/CallLogProviderTest.java | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java index b2674834..da2d0b8a 100644 --- a/src/com/android/providers/contacts/CallLogProvider.java +++ b/src/com/android/providers/contacts/CallLogProvider.java @@ -54,6 +54,7 @@ import android.provider.CallLog.Calls; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; +import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; @@ -1349,8 +1350,11 @@ public class CallLogProvider extends ContentProvider { PhoneAccountHandle phoneAccountHandle = (PhoneAccountHandle) arg; String iccId = null; try { - iccId = mSubscriptionManager.getActiveSubscriptionInfo( - Integer.parseInt(phoneAccountHandle.getId())).getIccId(); + SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo( + Integer.parseInt(phoneAccountHandle.getId())); + if (info != null) { + iccId = info.getIccId(); + } } catch (NumberFormatException nfe) { // Ignore the exception, iccId will remain null and be handled below. } diff --git a/tests/src/com/android/providers/contacts/CallLogProviderTest.java b/tests/src/com/android/providers/contacts/CallLogProviderTest.java index c7555823..a0a8483f 100644 --- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java +++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java @@ -18,6 +18,8 @@ package com.android.providers.contacts; import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED; +import static com.android.providers.contacts.ContactsProvider2.BACKGROUND_TASK_MIGRATE_PHONE_ACCOUNT_HANDLES; + import static org.mockito.Mockito.eq; import static org.mockito.Mockito.when; @@ -736,6 +738,16 @@ public class CallLogProviderTest extends BaseContactsProvider2Test { assertEquals(10, mCallLogProvider.getLastSyncTime(/* forShadow =*/ false)); } + public void testNullSubscriptionInfo() { + PhoneAccountHandle handle = new PhoneAccountHandle(new ComponentName( + TELEPHONY_PACKAGE, TELEPHONY_CLASS), TEST_PHONE_ACCOUNT_HANDLE_SUB_ID); + when(mSubscriptionManager.getActiveSubscriptionInfo(eq( + Integer.parseInt(TEST_PHONE_ACCOUNT_HANDLE_SUB_ID)))).thenReturn(null); + + mCallLogProvider.performBackgroundTask( + BACKGROUND_TASK_MIGRATE_PHONE_ACCOUNT_HANDLES, handle); + } + private ContentValues getDefaultValues(int callType) { ContentValues values = new ContentValues(); values.put(Calls.TYPE, callType); |