From e7deb67ca5d374e7a102bad0fbb6893d40674bfc Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 28 Jul 2022 13:49:16 -0700 Subject: [PATCH] [Sim Bouncer] Show sim pin view. Show sim pin view when sim is switched to a different locked sim. Bug: 239799178 Test: Added a unit test and also tested by adding 2 esims and switching between the two. I was able to reproduce the issue (the logs correspond to the bug) and was able to see the expected behavior after making the code change. Change-Id: If7735ab4a6ae637ccfa479cdea65c3848a107d03 --- .../keyguard/KeyguardViewMediator.java | 3 ++- .../keyguard/KeyguardViewMediatorTest.java | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 59c8aa0f20ade..f9b8ce28533b9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -635,13 +635,13 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, case TelephonyManager.SIM_STATE_PUK_REQUIRED: synchronized (KeyguardViewMediator.this) { mSimWasLocked.append(slotId, true); + mPendingPinLock = true; if (!mShowing) { if (DEBUG_SIM_STATES) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " + "showing; need to show keyguard so user can enter sim pin"); doKeyguardLocked(null); } else { - mPendingPinLock = true; resetStateLocked(); } } @@ -2984,6 +2984,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, pw.print(" mPendingReset: "); pw.println(mPendingReset); pw.print(" mPendingLock: "); pw.println(mPendingLock); pw.print(" wakeAndUnlocking: "); pw.println(mWakeAndUnlocking); + pw.print(" mPendingPinLock: "); pw.println(mPendingPinLock); } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java index a80aed7a6d187..8a36a68d189a3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -185,6 +185,31 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { verify(mStatusBarKeyguardViewManager, atLeast(1)).show(null); } + @Test + @TestableLooper.RunWithLooper(setAsMainLooper = true) + public void restoreBouncerWhenSimLockedAndKeyguardIsGoingAway_initiallyNotShowing() { + // When showing and provisioned + mViewMediator.onSystemReady(); + when(mUpdateMonitor.isDeviceProvisioned()).thenReturn(true); + mViewMediator.setShowingLocked(false); + + // and a SIM becomes locked and requires a PIN + mViewMediator.mUpdateCallback.onSimStateChanged( + 1 /* subId */, + 0 /* slotId */, + TelephonyManager.SIM_STATE_PIN_REQUIRED); + + // and the keyguard goes away + mViewMediator.setShowingLocked(false); + when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false); + mViewMediator.mUpdateCallback.onKeyguardVisibilityChanged(false); + + TestableLooper.get(this).processAllMessages(); + + // then make sure it comes back + verify(mStatusBarKeyguardViewManager, atLeast(1)).show(null); + } + @Test public void testBouncerPrompt_deviceLockedByAdmin() { // GIVEN no trust agents enabled and biometrics aren't enrolled