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

Commit 07ed8dac authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Only showKeyguard on strongAuthChanges for currUser" into main

parents 869ac441 41cdc47b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -870,6 +870,10 @@ public class KeyguardViewMediator implements CoreStartable,

        @Override
        public void onStrongAuthStateChanged(int userId) {
            // Do not react to strong auth changes of users that aren't the current user
            if (userId != mSelectedUserInteractor.getSelectedUserId()) {
                return;
            }
            if (mLockPatternUtils.isUserInLockdown(mSelectedUserInteractor.getSelectedUserId())) {
                doKeyguardLocked(null);
            }
+32 −1
Original line number Diff line number Diff line
@@ -490,7 +490,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        captureKeyguardUpdateMonitorCallback();
        assertFalse(mViewMediator.isShowingAndNotOccluded());

        // WHEN lockdown occurs
        // WHEN lockdown occurs for current user
        when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(0);
        when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true);
        mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0);

@@ -499,6 +500,36 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        assertTrue(mViewMediator.isShowingAndNotOccluded());
    }

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    public void onLockdown_onlyShowKeyguardIfMainUserHadStrongAuthChanged() {
        // GIVEN main user is in lockdown
        mViewMediator.onSystemReady();
        mViewMediator.setKeyguardEnabled(false);
        TestableLooper.get(this).processAllMessages();
        captureKeyguardUpdateMonitorCallback();
        assertFalse(mViewMediator.isShowingAndNotOccluded());

        int currentUserId = 0;
        int otherUserId = 10;
        when(mSelectedUserInteractor.getSelectedUserId()).thenReturn(currentUserId);
        when(mLockPatternUtils.isUserInLockdown(currentUserId)).thenReturn(true);

        // WHEN a different user's strong auth changes
        mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(otherUserId);

        // THEN keyguard is not shown
        TestableLooper.get(this).processAllMessages();
        assertFalse(mViewMediator.isShowingAndNotOccluded());

        // when the current user's strong auth changes
        mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(currentUserId);

        // THEN keyguard is shown
        TestableLooper.get(this).processAllMessages();
        assertTrue(mViewMediator.isShowingAndNotOccluded());
    }

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    public void showKeyguardAfterKeyguardNotEnabled() {