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

Commit bf3916b1 authored by Beverly's avatar Beverly
Browse files

Fully wake screen after udfps auth attempt from AOD

Particularly on failure/error.

Note: AuthController#onAodInterrupt isn't called in the first few
seconds of screen transioning to AOD; it'll only trigger after display
transitions to STATE_DOZE, so we have the wakeup logic in
KeyguardUpdateMonitor which uses the dozing state.

Test: manually check that auth failure on AOD brings user to lock screen
Bug: 175717712
Change-Id: I4f888f648ddb061068aa1963239dac45ba195074
parent f50afe81
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -66,8 +66,10 @@ import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
@@ -241,8 +243,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final boolean mIsPrimaryUser;
    private final boolean mIsAutomotive;
    private final AuthController mAuthController;
    private final PowerManager mPowerManager;
    private final StatusBarStateController mStatusBarStateController;
    private int mStatusBarState;
    private boolean mDozing;
    private final StatusBarStateController.StateListener mStatusBarStateControllerListener =
            new StatusBarStateController.StateListener() {
        @Override
@@ -250,6 +254,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            mStatusBarState = newState;
            updateBiometricListeningState();
        }

        @Override
        public void onDozingChanged(boolean dozing) {
            mDozing = dozing;
        }
    };

    HashMap<Integer, SimData> mSimDatas = new HashMap<>();
@@ -1294,17 +1303,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private final FingerprintManager.AuthenticationCallback mFingerprintAuthenticationCallback
            = new AuthenticationCallback() {
        private boolean mIsUdfpsRunningWhileDozing;

        @Override
        public void onAuthenticationFailed() {
            handleFingerprintAuthFailed();
            mAuthController.onCancelAodInterrupt();
            cancelAodInterrupt();
        }

        @Override
        public void onAuthenticationSucceeded(AuthenticationResult result) {
            Trace.beginSection("KeyguardUpdateMonitor#onAuthenticationSucceeded");
            handleFingerprintAuthenticated(result.getUserId(), result.isStrongBiometric());
            mAuthController.onCancelAodInterrupt();
            cancelAodInterrupt();
            Trace.endSection();
        }

@@ -1316,7 +1327,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        @Override
        public void onAuthenticationError(int errMsgId, CharSequence errString) {
            handleFingerprintError(errMsgId, errString.toString());
            mAuthController.onCancelAodInterrupt();
            cancelAodInterrupt();
        }

        @Override
@@ -1327,12 +1338,25 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        @Override
        public void onUdfpsPointerDown(int sensorId) {
            Log.d(TAG, "onUdfpsPointerDown, sensorId: " + sensorId);

            if (mDozing) {
                mIsUdfpsRunningWhileDozing = true;
            }
        }

        @Override
        public void onUdfpsPointerUp(int sensorId) {
            Log.d(TAG, "onUdfpsPointerUp, sensorId: " + sensorId);
        }

        private void cancelAodInterrupt() {
            if (mIsUdfpsRunningWhileDozing) {
                mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
                        "com.android.systemui:AOD_INTERRUPT_END");
            }
            mAuthController.onCancelAodInterrupt();
            mIsUdfpsRunningWhileDozing = false;
        }
    };

    private final FaceManager.FaceDetectionCallback mFaceDetectionCallback
@@ -1619,6 +1643,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            LockPatternUtils lockPatternUtils,
            AuthController authController,
            TelephonyListenerManager telephonyListenerManager,
            PowerManager powerManager,
            FeatureFlags featureFlags) {
        mContext = context;
        mSubscriptionManager = SubscriptionManager.from(context);
@@ -1631,8 +1656,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(mStatusBarStateControllerListener);
        mStatusBarState = mStatusBarStateController.getState();
        mDozing = mStatusBarStateController.isDozing();
        mLockPatternUtils = lockPatternUtils;
        mAuthController = authController;
        mPowerManager = powerManager;
        dumpManager.registerDumpable(getClass().getName(), this);

        mHandler = new Handler(mainLooper) {
+4 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.PowerManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.ServiceState;
@@ -164,6 +165,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    @Mock
    private AuthController mAuthController;
    @Mock
    private PowerManager mPowerManager;
    @Mock
    private TelephonyListenerManager mTelephonyListenerManager;
    @Mock
    private FeatureFlags mFeatureFlags;
@@ -926,7 +929,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
                    mBroadcastDispatcher, mDumpManager,
                    mRingerModeTracker, mBackgroundExecutor,
                    mStatusBarStateController, mLockPatternUtils,
                    mAuthController, mTelephonyListenerManager, mFeatureFlags);
                    mAuthController, mTelephonyListenerManager, mPowerManager, mFeatureFlags);
            setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
        }