Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +66 −52 Original line number Diff line number Diff line Loading @@ -585,9 +585,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } private void handleSimSubscriptionInfoChanged() { Assert.isMainThread(); mSimLogger.v("onSubscriptionInfoChanged()"); List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); mBackgroundExecutor.execute(() -> { final List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); mMainExecutor.execute(() -> { if (!subscriptionInfos.isEmpty()) { for (SubscriptionInfo subInfo : subscriptionInfos) { mSimLogger.logSubInfo(subInfo); Loading @@ -596,22 +598,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mSimLogger.v("onSubscriptionInfoChanged: list is null"); } // Hack level over 9000: Because the subscription id is not yet valid when we see the // first update in handleSimStateChange, we need to force refresh all SIM states // Hack level over 9000: Because the subscription id is not yet valid when we see // the first update in handleSimStateChange, we need to force refresh all SIM states // so the subscription id for them is consistent. ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>(); Set<Integer> activeSubIds = new HashSet<>(); for (int i = 0; i < subscriptionInfos.size(); i++) { SubscriptionInfo info = subscriptionInfos.get(i); activeSubIds.add(info.getSubscriptionId()); boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex()); boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex()); if (changed) { changedSubscriptions.add(info); } } // It is possible for active subscriptions to become invalid (-1), and these will not be // present in the subscriptionInfo list // It is possible for active subscriptions to become invalid (-1), and these will // not be present in the subscriptionInfo list synchronized (mSimDataLockObject) { Iterator<Map.Entry<Integer, SimData>> iter = mSimDatas.entrySet().iterator(); while (iter.hasNext()) { Loading @@ -631,7 +634,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } for (int i = 0; i < changedSubscriptions.size(); i++) { SimData data = mSimDatas.get(changedSubscriptions.get(i).getSubscriptionId()); SimData data = mSimDatas.get( changedSubscriptions.get(i).getSubscriptionId()); for (int j = 0; j < mCallbacks.size(); j++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); if (cb != null) { Loading @@ -641,6 +645,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } callbacksRefreshCarrierInfo(); } }); }); } private void handleAirplaneModeChanged() { Loading Loading @@ -2523,6 +2529,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab if (mUserTracker.isUserSwitching()) { handleUserSwitching(mUserTracker.getUserId(), () -> {}); } // Force the cache to be initialized mBackgroundExecutor.execute(() -> { getSubscriptionInfo(/* forceReload= */ true); }); } @VisibleForTesting Loading Loading @@ -3851,12 +3862,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab * @see #isSimPinSecure(int) */ public boolean isSimPinSecure() { // True if any SIM is pin secure for (SubscriptionInfo info : getSubscriptionInfo(false /* forceReload */)) { if (isSimPinSecure(getSimState(info.getSubscriptionId()))) return true; synchronized (mSimDataLockObject) { for (SimData data : mSimDatas.values()) { if (isSimPinSecure(data.simState)) { return true; } } return false; } } public int getSimState(int subId) { synchronized (mSimDataLockObject) { Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -2266,6 +2266,23 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { TelephonyManager.SIM_STATE_PIN_REQUIRED); } @Test public void isSimPinSecureReturnsFalseWhenEmpty() { assertThat(mKeyguardUpdateMonitor.isSimPinSecure()).isFalse(); } @Test public void isSimPinSecureReturnsTrueWhenOneSlotIsLocked() { // Slot 0 is locked mKeyguardUpdateMonitor.handleSimStateChange(10, 0, TelephonyManager.SIM_STATE_PIN_REQUIRED); // Slot 1 is not ready mKeyguardUpdateMonitor.handleSimStateChange(11, 1, TelephonyManager.SIM_STATE_NOT_READY); assertThat(mKeyguardUpdateMonitor.isSimPinSecure()).isTrue(); } @Test public void onAuthEnrollmentChangesCallbacksAreNotified() { KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class); Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +66 −52 Original line number Diff line number Diff line Loading @@ -585,9 +585,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } private void handleSimSubscriptionInfoChanged() { Assert.isMainThread(); mSimLogger.v("onSubscriptionInfoChanged()"); List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); mBackgroundExecutor.execute(() -> { final List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true /* forceReload */); mMainExecutor.execute(() -> { if (!subscriptionInfos.isEmpty()) { for (SubscriptionInfo subInfo : subscriptionInfos) { mSimLogger.logSubInfo(subInfo); Loading @@ -596,22 +598,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mSimLogger.v("onSubscriptionInfoChanged: list is null"); } // Hack level over 9000: Because the subscription id is not yet valid when we see the // first update in handleSimStateChange, we need to force refresh all SIM states // Hack level over 9000: Because the subscription id is not yet valid when we see // the first update in handleSimStateChange, we need to force refresh all SIM states // so the subscription id for them is consistent. ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>(); Set<Integer> activeSubIds = new HashSet<>(); for (int i = 0; i < subscriptionInfos.size(); i++) { SubscriptionInfo info = subscriptionInfos.get(i); activeSubIds.add(info.getSubscriptionId()); boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex()); boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex()); if (changed) { changedSubscriptions.add(info); } } // It is possible for active subscriptions to become invalid (-1), and these will not be // present in the subscriptionInfo list // It is possible for active subscriptions to become invalid (-1), and these will // not be present in the subscriptionInfo list synchronized (mSimDataLockObject) { Iterator<Map.Entry<Integer, SimData>> iter = mSimDatas.entrySet().iterator(); while (iter.hasNext()) { Loading @@ -631,7 +634,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } for (int i = 0; i < changedSubscriptions.size(); i++) { SimData data = mSimDatas.get(changedSubscriptions.get(i).getSubscriptionId()); SimData data = mSimDatas.get( changedSubscriptions.get(i).getSubscriptionId()); for (int j = 0; j < mCallbacks.size(); j++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); if (cb != null) { Loading @@ -641,6 +645,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } callbacksRefreshCarrierInfo(); } }); }); } private void handleAirplaneModeChanged() { Loading Loading @@ -2523,6 +2529,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab if (mUserTracker.isUserSwitching()) { handleUserSwitching(mUserTracker.getUserId(), () -> {}); } // Force the cache to be initialized mBackgroundExecutor.execute(() -> { getSubscriptionInfo(/* forceReload= */ true); }); } @VisibleForTesting Loading Loading @@ -3851,12 +3862,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab * @see #isSimPinSecure(int) */ public boolean isSimPinSecure() { // True if any SIM is pin secure for (SubscriptionInfo info : getSubscriptionInfo(false /* forceReload */)) { if (isSimPinSecure(getSimState(info.getSubscriptionId()))) return true; synchronized (mSimDataLockObject) { for (SimData data : mSimDatas.values()) { if (isSimPinSecure(data.simState)) { return true; } } return false; } } public int getSimState(int subId) { synchronized (mSimDataLockObject) { Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -2266,6 +2266,23 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { TelephonyManager.SIM_STATE_PIN_REQUIRED); } @Test public void isSimPinSecureReturnsFalseWhenEmpty() { assertThat(mKeyguardUpdateMonitor.isSimPinSecure()).isFalse(); } @Test public void isSimPinSecureReturnsTrueWhenOneSlotIsLocked() { // Slot 0 is locked mKeyguardUpdateMonitor.handleSimStateChange(10, 0, TelephonyManager.SIM_STATE_PIN_REQUIRED); // Slot 1 is not ready mKeyguardUpdateMonitor.handleSimStateChange(11, 1, TelephonyManager.SIM_STATE_NOT_READY); assertThat(mKeyguardUpdateMonitor.isSimPinSecure()).isTrue(); } @Test public void onAuthEnrollmentChangesCallbacksAreNotified() { KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class); Loading