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

Commit 47cdb4b2 authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "ActiveUnlock: run wake_unfolded logic on OPENED" into tm-qpr-dev am: 18ed251a

parents 86dbfdd3 18ed251a
Loading
Loading
Loading
Loading
+33 −17
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STARTED_WAK
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;


import android.annotation.AnyThread;
import android.annotation.AnyThread;
@@ -1862,6 +1863,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        updateFaceListeningState(BIOMETRIC_ACTION_STOP,
                        updateFaceListeningState(BIOMETRIC_ACTION_STOP,
                                FACE_AUTH_UPDATED_POSTURE_CHANGED);
                                FACE_AUTH_UPDATED_POSTURE_CHANGED);
                    }
                    }
                    if (mPostureState == DEVICE_POSTURE_OPENED) {
                        mLogger.d("Posture changed to open - attempting to request active unlock");
                        requestActiveUnlockFromWakeReason(PowerManager.WAKE_REASON_UNFOLD_DEVICE,
                                false);
                    }
                }
                }
            };
            };


@@ -1988,26 +1994,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            FACE_AUTH_UPDATED_STARTED_WAKING_UP.setExtraInfo(pmWakeReason);
            FACE_AUTH_UPDATED_STARTED_WAKING_UP.setExtraInfo(pmWakeReason);
            updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
            updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
                    FACE_AUTH_UPDATED_STARTED_WAKING_UP);
                    FACE_AUTH_UPDATED_STARTED_WAKING_UP);

            final ActiveUnlockConfig.ActiveUnlockRequestOrigin requestOrigin =
                    mActiveUnlockConfig.isWakeupConsideredUnlockIntent(pmWakeReason)
                            ? ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT
                            : ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE;
            final String reason = "wakingUp - " + PowerManager.wakeReasonToString(pmWakeReason);
            if (mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(pmWakeReason)) {
                requestActiveUnlockDismissKeyguard(
                        requestOrigin,
                        reason
                );
            } else {
                requestActiveUnlock(
                        requestOrigin,
                        reason
                );
            }
        } else {
        } else {
            mLogger.logSkipUpdateFaceListeningOnWakeup(pmWakeReason);
            mLogger.logSkipUpdateFaceListeningOnWakeup(pmWakeReason);
        }
        }
        requestActiveUnlockFromWakeReason(pmWakeReason, true);


        for (int i = 0; i < mCallbacks.size(); i++) {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
@@ -2640,6 +2630,32 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
        }
    }
    }


    private void requestActiveUnlockFromWakeReason(@PowerManager.WakeReason int wakeReason,
            boolean powerManagerWakeup) {
        if (!mFaceWakeUpTriggersConfig.shouldTriggerFaceAuthOnWakeUpFrom(wakeReason)) {
            mLogger.logActiveUnlockRequestSkippedForWakeReasonDueToFaceConfig(wakeReason);
            return;
        }

        final ActiveUnlockConfig.ActiveUnlockRequestOrigin requestOrigin =
                mActiveUnlockConfig.isWakeupConsideredUnlockIntent(wakeReason)
                        ? ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT
                        : ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE;
        final String reason = "wakingUp - " + PowerManager.wakeReasonToString(wakeReason)
                + " powerManagerWakeup=" + powerManagerWakeup;
        if (mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(wakeReason)) {
            requestActiveUnlockDismissKeyguard(
                    requestOrigin,
                    reason
            );
        } else {
            requestActiveUnlock(
                    requestOrigin,
                    reason
            );
        }
    }

    /**
    /**
     * Attempts to trigger active unlock from trust agent.
     * Attempts to trigger active unlock from trust agent.
     */
     */
+10 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,16 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        )
        )
    }
    }


    fun logActiveUnlockRequestSkippedForWakeReasonDueToFaceConfig(wakeReason: Int) {
        logBuffer.log(
            "ActiveUnlock",
            DEBUG,
            { int1 = wakeReason },
            { "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
                    " reason=${PowerManager.wakeReasonToString(int1)}" }
        )
    }

    fun logAuthInterruptDetected(active: Boolean) {
    fun logAuthInterruptDetected(active: Boolean) {
        logBuffer.log(TAG, DEBUG, { bool1 = active }, { "onAuthInterruptDetected($bool1)" })
        logBuffer.log(TAG, DEBUG, { bool1 = active }, { "onAuthInterruptDetected($bool1)" })
    }
    }
+51 −0
Original line number Original line Diff line number Diff line
@@ -2432,6 +2432,57 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
                eq(false));
                eq(false));
    }
    }


    @Test
    public void unfoldFromPostureChange_requestActiveUnlock_forceDismissKeyguard()
            throws RemoteException {
        // GIVEN shouldTriggerActiveUnlock
        keyguardIsVisible();
        when(mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())).thenReturn(true);

        // GIVEN active unlock triggers on wakeup
        when(mActiveUnlockConfig.shouldAllowActiveUnlockFromOrigin(
                ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE))
                .thenReturn(true);

        // GIVEN an unfold should force dismiss the keyguard
        when(mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(
                PowerManager.WAKE_REASON_UNFOLD_DEVICE)).thenReturn(true);

        // WHEN device posture changes to unfold
        deviceInPostureStateOpened();
        mTestableLooper.processAllMessages();

        // THEN request unlock with a keyguard dismissal
        verify(mTrustManager).reportUserRequestedUnlock(eq(KeyguardUpdateMonitor.getCurrentUser()),
                eq(true));
    }


    @Test
    public void unfoldFromPostureChange_requestActiveUnlock_noDismissKeyguard()
            throws RemoteException {
        // GIVEN shouldTriggerActiveUnlock on wake from UNFOLD_DEVICE
        keyguardIsVisible();
        when(mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())).thenReturn(true);

        // GIVEN active unlock triggers on wakeup
        when(mActiveUnlockConfig.shouldAllowActiveUnlockFromOrigin(
                ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE))
                .thenReturn(true);

        // GIVEN an unfold should NOT force dismiss the keyguard
        when(mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(
                PowerManager.WAKE_REASON_UNFOLD_DEVICE)).thenReturn(false);

        // WHEN device posture changes to unfold
        deviceInPostureStateOpened();
        mTestableLooper.processAllMessages();

        // THEN request unlock WITHOUT a keyguard dismissal
        verify(mTrustManager).reportUserRequestedUnlock(eq(KeyguardUpdateMonitor.getCurrentUser()),
                eq(false));
    }

    @Test
    @Test
    public void detectFingerprint_onTemporaryLockoutReset_authenticateFingerprint() {
    public void detectFingerprint_onTemporaryLockoutReset_authenticateFingerprint() {
        ArgumentCaptor<FingerprintManager.LockoutResetCallback> fpLockoutResetCallbackCaptor =
        ArgumentCaptor<FingerprintManager.LockoutResetCallback> fpLockoutResetCallbackCaptor =