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

Commit 9bae9c2d authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Avoid unwanted wakeAndUnLock mode for face

Test: press power repeatedly on lock screen
Bug: 132846921
Fixes: 130766403
Bug: 130327302
Change-Id: Ic11914ad220a0c8f81f0d28d5f999fcf970ccdeb
parent 3db3383e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -748,6 +748,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private void handleFaceAuthenticated(int authUserId) {
        Trace.beginSection("KeyGuardUpdateMonitor#handlerFaceAuthenticated");
        try {
            if (mGoingToSleep) {
                Log.d(TAG, "Aborted successful auth because device is going to sleep.");
                return;
            }
            final int userId;
            try {
                userId = ActivityManager.getService().getCurrentUser().id;
+12 −3
Original line number Diff line number Diff line
@@ -365,16 +365,23 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
    private int calculateMode(BiometricSourceType biometricSourceType) {
        boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed();
        boolean deviceDreaming = mUpdateMonitor.isDreaming();
        boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE
                && !mKeyguardBypassController.getBypassEnabled();
        boolean face = biometricSourceType == BiometricSourceType.FACE;
        boolean faceStayingOnKeyguard = face && !mKeyguardBypassController.getBypassEnabled();

        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
                return MODE_ONLY_WAKE;
            } else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
                return faceStayingOnKeyguard ? MODE_NONE : MODE_WAKE_AND_UNLOCK_PULSING;
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
            } else if (!face && (unlockingAllowed || !mUnlockMethodCache.isMethodSecure())) {
                return MODE_WAKE_AND_UNLOCK;
            } else if (face) {
                if (!(mDozeScrimController.isPulsing() && !unlockingAllowed)) {
                    Log.wtf(TAG, "Face somehow arrived when the device was not interactive");
                }
                // We could theoretically return MODE_NONE, but this means that the device
                // would be not interactive, unlocked, and the user would not see the device state.
                return MODE_ONLY_WAKE;
            } else {
                return MODE_SHOW_BOUNCER;
            }
@@ -389,6 +396,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
                return MODE_DISMISS_BOUNCER;
            } else if (unlockingAllowed) {
                return faceStayingOnKeyguard ? MODE_ONLY_WAKE : MODE_UNLOCK;
            } else if (face) {
                return MODE_NONE;
            } else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) {
                return MODE_SHOW_BOUNCER;
            }
+0 −7
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone
import android.content.Context
import android.hardware.face.FaceManager
import android.provider.Settings
import com.android.internal.annotations.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.tuner.TunerService

@@ -59,10 +58,4 @@ class KeyguardBypassController {
            }
        }, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD)
    }

    @VisibleForTesting
    constructor(bypassEnabled: Boolean, unlockMethodCache: UnlockMethodCache) {
        this.bypassEnabled = bypassEnabled
        this.unlockMethodCache = unlockMethodCache
    }
}
+7 −15
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    private UnlockMethodCache mUnlockMethodCache;
    @Mock
    private Handler mHandler;
    @Mock
    private KeyguardBypassController mKeyguardBypassController;
    private BiometricUnlockController mBiometricUnlockController;

    @Before
@@ -83,8 +85,9 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager);
        mDependency.injectTestDependency(StatusBarWindowController.class,
                mStatusBarWindowController);
        mBiometricUnlockController = new TestableBiometricUnlockController(
                false /* faceDismissesKeyguard */);
        mBiometricUnlockController = new BiometricUnlockController(mContext, mDozeScrimController,
                mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
                mHandler, mUpdateMonitor, 0 /* wakeUpDelay */, mKeyguardBypassController);
        mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
    }

@@ -139,9 +142,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    }

    @Test
    public void onBiometricAuthenticated_whenFace_dismissingKeyguard() {
        mBiometricUnlockController = new TestableBiometricUnlockController(
                true /* faceDismissesKeyguard */);
    public void onBiometricAuthenticated_whenFace_andBypass_dismissKeyguard() {
        when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true);
        mBiometricUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);

        when(mUpdateMonitor.isUnlockingWithBiometricAllowed()).thenReturn(true);
@@ -184,14 +186,4 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mBiometricUnlockController.onFinishedGoingToSleep(-1);
        verify(mHandler).post(any());
    }

    private class TestableBiometricUnlockController extends BiometricUnlockController {

        TestableBiometricUnlockController(boolean faceDismissesKeyguard) {
            super(mContext, mDozeScrimController,
                    mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
                    mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
                    new KeyguardBypassController(faceDismissesKeyguard, mUnlockMethodCache));
        }
    }
}