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

Commit c826f406 authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Fix face auth from bouncer over dream" into main

parents ab5f8b23 2730dd7a
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.phone;

import static android.service.dreams.Flags.FLAG_DREAMS_V2;

import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK;

@@ -38,6 +40,7 @@ import android.hardware.fingerprint.FingerprintManager;
import android.os.Handler;
import android.os.PowerManager;
import android.os.UserHandle;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableResources;
import android.view.ViewRootImpl;
@@ -336,6 +339,38 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                .isEqualTo(BiometricUnlockController.MODE_SHOW_BOUNCER);
    }

    @Test
    public void onBiometricAuthenticated_whenFaceAndDreaming_dontDismissKeyguard() {
        when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
        when(mUpdateMonitor.isDreaming()).thenReturn(true);
        when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
        // the value of isStrongBiometric doesn't matter here since we only care about the returned
        // value of isUnlockingWithBiometricAllowed()
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager, never()).notifyKeyguardAuthenticated(anyBoolean());
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_ONLY_WAKE);
    }

    @Test
    @EnableFlags(FLAG_DREAMS_V2)
    public void onBiometricAuthenticated_whenFaceOnBouncerAndDreaming_dismissKeyguard() {
        when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
        when(mUpdateMonitor.isDreaming()).thenReturn(true);
        when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
        when(mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()).thenReturn(true);
        // the value of isStrongBiometric doesn't matter here since we only care about the returned
        // value of isUnlockingWithBiometricAllowed()
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager, never()).notifyKeyguardAuthenticated(anyBoolean());
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM);
    }

    @Test
    public void onBiometricAuthenticated_onLockScreen() {
        // GIVEN not dozing
+7 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone;

import static android.app.StatusBarManager.SESSION_KEYGUARD;
import static android.service.dreams.Flags.dreamsV2;

import android.annotation.IntDef;
import android.content.res.Resources;
@@ -662,6 +663,9 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        final boolean deviceDreaming = mUpdateMonitor.isDreaming();
        final boolean bypass = mKeyguardBypassController.getBypassEnabled()
                || mAuthController.isUdfpsFingerDown();
        final boolean isBouncerShowing = mKeyguardViewController.primaryBouncerIsOrWillBeShowing()
                || mKeyguardTransitionInteractor.getCurrentState()
                    == KeyguardState.ALTERNATE_BOUNCER;

        logCalculateModeForPassiveAuth(unlockingAllowed, deviceInteractive, isKeyguardShowing,
                deviceDreaming, bypass, isStrongBiometric);
@@ -685,15 +689,14 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
            }
        }
        if (unlockingAllowed && deviceDreaming) {
            return bypass ? MODE_WAKE_AND_UNLOCK_FROM_DREAM : MODE_ONLY_WAKE;
            final boolean wakeAndUnlock = bypass || (dreamsV2() && isBouncerShowing);
            return wakeAndUnlock ? MODE_WAKE_AND_UNLOCK_FROM_DREAM : MODE_ONLY_WAKE;
        }
        if (unlockingAllowed && mKeyguardStateController.isOccluded()) {
            return MODE_UNLOCK_COLLAPSING;
        }
        if (isKeyguardShowing) {
            if ((mKeyguardViewController.primaryBouncerIsOrWillBeShowing()
                    || mKeyguardTransitionInteractor.getCurrentState()
                    == KeyguardState.ALTERNATE_BOUNCER) && unlockingAllowed) {
            if (isBouncerShowing && unlockingAllowed) {
                return MODE_DISMISS_BOUNCER;
            } else if (unlockingAllowed && bypass) {
                return MODE_UNLOCK_COLLAPSING;