diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-10 20:01:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-10 20:01:00 +0000 |
commit | c2c46d7473f7c81603e1c1cbffc1ac78b947ce98 (patch) | |
tree | ffb7e6ae2e264091a81cb5307f958af41cbd3ec5 | |
parent | 19ff460ab7e2779a6b8c0af6f71def46cd5ed266 (diff) | |
parent | 68d84086a41208c74d116460d81131964c865eeb (diff) | |
download | ImsServiceEntitlement-c2c46d7473f7c81603e1c1cbffc1ac78b947ce98.tar.gz |
Snap for 7901677 from 68d84086a41208c74d116460d81131964c865eeb to sc-platform-releaseandroid-platform-12.0.0_r9android-platform-12.0.0_r8android-platform-12.0.0_r7android-platform-12.0.0_r6android-platform-12.0.0_r5android-platform-12.0.0_r4android-platform-12.0.0_r31android-platform-12.0.0_r30android-platform-12.0.0_r3android-platform-12.0.0_r29android-platform-12.0.0_r28android-platform-12.0.0_r27android-platform-12.0.0_r26android-platform-12.0.0_r25android-platform-12.0.0_r24android-platform-12.0.0_r23android-platform-12.0.0_r22android-platform-12.0.0_r21android-platform-12.0.0_r20android-platform-12.0.0_r2android-platform-12.0.0_r19android-platform-12.0.0_r18android-platform-12.0.0_r17android-platform-12.0.0_r16android-platform-12.0.0_r15android-platform-12.0.0_r14android-platform-12.0.0_r13android-platform-12.0.0_r12android-platform-12.0.0_r11android-platform-12.0.0_r10android12-platform-release
Change-Id: I18a06b866a5c435ab44a405278cd7656417b4b4a
3 files changed, 36 insertions, 3 deletions
diff --git a/src/com/android/imsserviceentitlement/ImsEntitlementReceiver.java b/src/com/android/imsserviceentitlement/ImsEntitlementReceiver.java index dc78b0a..d1d3a97 100644 --- a/src/com/android/imsserviceentitlement/ImsEntitlementReceiver.java +++ b/src/com/android/imsserviceentitlement/ImsEntitlementReceiver.java @@ -16,6 +16,8 @@ package com.android.imsserviceentitlement; +import static android.telephony.TelephonyManager.SIM_STATE_LOADED; + import static com.android.imsserviceentitlement.entitlement.EntitlementConfiguration.ClientBehavior.NEEDS_TO_RESET; import static com.android.imsserviceentitlement.entitlement.EntitlementConfiguration.ClientBehavior.VALID_DURING_VALIDITY; import static com.android.imsserviceentitlement.entitlement.EntitlementConfiguration.ClientBehavior.VALID_WITHOUT_DURATION; @@ -68,6 +70,8 @@ public class ImsEntitlementReceiver extends BroadcastReceiver { SubscriptionManager.INVALID_SIM_SLOT_INDEX); Dependencies dependencies = createDependency(context, currentSubId); if (!dependencies.userManager.isSystemUser() + || !SubscriptionManager.isValidSubscriptionId(currentSubId) + || dependencies.telephonyUtils.getSimApplicationState() != SIM_STATE_LOADED || !TelephonyUtils.isImsProvisioningRequired(context, currentSubId)) { return; } @@ -89,9 +93,6 @@ public class ImsEntitlementReceiver extends BroadcastReceiver { private void handleCarrierConfigChanged( Context context, int currentSubId, int slotId, JobManager jobManager, PendingResult result) { - if (!SubscriptionManager.isValidSubscriptionId(currentSubId)) { - return; - } boolean shouldQuery = false; // Handle device boot up. diff --git a/src/com/android/imsserviceentitlement/utils/TelephonyUtils.java b/src/com/android/imsserviceentitlement/utils/TelephonyUtils.java index 2601fd8..e968c2f 100644 --- a/src/com/android/imsserviceentitlement/utils/TelephonyUtils.java +++ b/src/com/android/imsserviceentitlement/utils/TelephonyUtils.java @@ -98,6 +98,11 @@ public class TelephonyUtils { return mTelephonyManager.getSimSpecificCarrierId(); } + /** Returns SIM card application state. */ + public int getSimApplicationState() { + return mTelephonyManager.getSimApplicationState(); + } + /** * Returns {@code true} if the {@code subId} still point to a actived SIM; {@code false} * otherwise. diff --git a/tests/unittests/src/com/android/imsserviceentitlement/ImsEntitlementReceiverTest.java b/tests/unittests/src/com/android/imsserviceentitlement/ImsEntitlementReceiverTest.java index dbea9a1..444db10 100644 --- a/tests/unittests/src/com/android/imsserviceentitlement/ImsEntitlementReceiverTest.java +++ b/tests/unittests/src/com/android/imsserviceentitlement/ImsEntitlementReceiverTest.java @@ -16,6 +16,9 @@ package com.android.imsserviceentitlement; +import static android.telephony.TelephonyManager.SIM_STATE_LOADED; +import static android.telephony.TelephonyManager.SIM_STATE_PIN_REQUIRED; + import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.never; @@ -117,6 +120,7 @@ public class ImsEntitlementReceiverTest { new EntitlementConfiguration(mContext, SUB_ID).reset(); when(mMockUserManager.isSystemUser()).thenReturn(true); + when(mMockTelephonyUtils.getSimApplicationState()).thenReturn(SIM_STATE_LOADED); setLastSubId(LAST_SUB_ID, 0); setupCarrierConfig(); @@ -133,6 +137,29 @@ public class ImsEntitlementReceiverTest { } @Test + public void onReceive_simChanged_simPinLockedThenLoaded() { + // SIM PIN locked + when(mMockTelephonyUtils.getSimApplicationState()).thenReturn(SIM_STATE_PIN_REQUIRED); + + mReceiver.onReceive(mContext, getCarrierConfigChangedIntent(SUB_ID, /* slotId= */ 0)); + + // no-op + assertThat( + new EntitlementConfiguration(mContext, LAST_SUB_ID).getVoWifiStatus()).isEqualTo(1); + verify(mMockJobManager, never()).queryEntitlementStatusOnceNetworkReady(); + + // SIM LOADED + when(mMockTelephonyUtils.getSimApplicationState()).thenReturn(SIM_STATE_LOADED); + + mReceiver.onReceive(mContext, getCarrierConfigChangedIntent(SUB_ID, /* slotId= */ 0)); + + // configuration reset and entitlement query scheduled. + assertThat( + new EntitlementConfiguration(mContext, LAST_SUB_ID).getVoWifiStatus()).isEqualTo(2); + verify(mMockJobManager, times(1)).queryEntitlementStatusOnceNetworkReady(); + } + + @Test public void onReceive_theSameSim_dataNotReset() { mReceiver.onReceive( mContext, getCarrierConfigChangedIntent(LAST_SUB_ID, /* slotId= */ 0)); |