Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6190b8a7 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Don't reset mPendingPinLock on keyguardGoingAway

Only reset mPendingPinLock on primary bouncer changes
if the primary bouncer is about to show and the keyguard
is NOT going away.

Test: atest KeyguardViewMediatorTest
Fixes: 285023830
Change-Id: I85c5b51b989211a85d309630b9474536da856048
parent 57b293ef
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1201,7 +1201,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        @Override
        public void onPrimaryBouncerShowingChanged() {
            synchronized (KeyguardViewMediator.this) {
                if (mKeyguardStateController.isPrimaryBouncerShowing()) {
                if (mKeyguardStateController.isPrimaryBouncerShowing()
                        && !mKeyguardStateController.isKeyguardGoingAway()) {
                    mPendingPinLock = false;
                }
                adjustStatusBarLocked(mKeyguardStateController.isPrimaryBouncerShowing(), false);
+33 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
    private @Mock ShadeWindowLogger mShadeWindowLogger;
    private @Captor ArgumentCaptor<KeyguardUpdateMonitorCallback>
            mKeyguardUpdateMonitorCallbackCaptor;
    private @Captor ArgumentCaptor<KeyguardStateController.Callback>
            mKeyguardStateControllerCallback;
    private DeviceConfigProxy mDeviceConfig = new DeviceConfigProxyFake();
    private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());

@@ -595,6 +597,33 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        );
    }

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    public void pendingPinLockOnKeyguardGoingAway_doKeyguardLockedOnKeyguardVisibilityChanged() {
        // GIVEN SIM_STATE_PIN_REQUIRED
        mViewMediator.onSystemReady();
        final KeyguardUpdateMonitorCallback keyguardUpdateMonitorCallback =
                mViewMediator.mUpdateCallback;
        keyguardUpdateMonitorCallback.onSimStateChanged(0, 0,
                TelephonyManager.SIM_STATE_PIN_REQUIRED);
        TestableLooper.get(this).processAllMessages();

        // ...and then the primary bouncer shows while the keyguard is going away
        captureKeyguardStateControllerCallback();
        when(mKeyguardStateController.isPrimaryBouncerShowing()).thenReturn(true);
        when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(true);
        mKeyguardStateControllerCallback.getValue().onPrimaryBouncerShowingChanged();
        TestableLooper.get(this).processAllMessages();

        // WHEN keyguard visibility becomes FALSE
        mViewMediator.setShowingLocked(false);
        keyguardUpdateMonitorCallback.onKeyguardVisibilityChanged(false);
        TestableLooper.get(this).processAllMessages();

        // THEN keyguard shows due to the pending SIM PIN lock
        assertTrue(mViewMediator.isShowingAndNotOccluded());
    }

    private void createAndStartViewMediator() {
        mViewMediator = new KeyguardViewMediator(
                mContext,
@@ -638,4 +667,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
    private void captureKeyguardUpdateMonitorCallback() {
        verify(mUpdateMonitor).registerCallback(mKeyguardUpdateMonitorCallbackCaptor.capture());
    }

    private void captureKeyguardStateControllerCallback() {
        verify(mKeyguardStateController).addCallback(mKeyguardStateControllerCallback.capture());
    }
}