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

Commit 991998d5 authored by beverlyt's avatar beverlyt Committed by Android Build Coastguard Worker
Browse files

Check the strongAuthTracker for lockdown instead of LockPatternUtils

LockPatternUtils and the StrongAuthTracker check for
lockdown may be out of sync, so always check the
KeyguardUpdateMonitor's strong auth tracker for
lockdown.

Test: atest KeyguardViewMediatorTest
Test: pin an app; lock down device;
observe keyguard always shows (repeat 10x times)
Bug: 438973280
Flag: EXEMPT CVE_FIX

(cherry picked from commit 5c25e76eb886ad3508103b486b146b6920c8c651)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:0f786445c61e9bf8c9eacae9a8075f05ea9d36dc
Merged-In: I076f5a8cacd14fc8ab8893aedf98ff831a9c195f
Change-Id: I076f5a8cacd14fc8ab8893aedf98ff831a9c195f
parent 5776485a
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -256,8 +256,11 @@ public class KeyguardUpdateMonitorCallback {
            BiometricSourceType biometricSourceType) { }

    /**
     * Called when the state that the user hasn't used strong authentication since quite some time
     * has changed.
     * Called when the strong auth state changes and primary auth may be required.
     * If responding to a change in strong auth state from this method, use
     * {@link KeyguardUpdateMonitor} as the source for truth for strong auth state.
     * For example:
     *  - {@link KeyguardUpdateMonitor#isUserInLockdown(int)}
     */
    public void onStrongAuthStateChanged(int userId) { }

+3 −3
Original line number Diff line number Diff line
@@ -789,7 +789,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

        @Override
        public void onStrongAuthStateChanged(int userId) {
            if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
            if (mUpdateMonitor.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
                doKeyguardLocked(null);
            }
        }
@@ -1954,7 +1954,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            mExternallyEnabled = enabled;

            if (!enabled && mShowing) {
                if (mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
                if (mUpdateMonitor.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
                    Log.d(TAG, "keyguardEnabled(false) overridden by user lockdown");
                    return;
                }
@@ -2193,7 +2193,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

        // if another app is disabling us, don't show
        if (!mExternallyEnabled
                && !mLockPatternUtils.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
                && !mUpdateMonitor.isUserInLockdown(KeyguardUpdateMonitor.getCurrentUser())) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
            notifyLockNowCallback();
            mNeedToReshowWhenReenabled = true;
+2 −2
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        assertFalse(mViewMediator.isShowingAndNotOccluded());

        // WHEN lockdown occurs
        when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true);
        when(mUpdateMonitor.isUserInLockdown(anyInt())).thenReturn(true);
        mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0);

        // THEN keyguard is shown
@@ -351,7 +351,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        mViewMediator.setKeyguardEnabled(true);
        TestableLooper.get(this).processAllMessages();
        captureKeyguardUpdateMonitorCallback();
        when(mLockPatternUtils.isUserInLockdown(anyInt())).thenReturn(true);
        when(mUpdateMonitor.isUserInLockdown(anyInt())).thenReturn(true);
        mKeyguardUpdateMonitorCallbackCaptor.getValue().onStrongAuthStateChanged(0);
        assertTrue(mViewMediator.isShowingAndNotOccluded());