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

Commit c9207a2d authored by Lucas Dupin's avatar Lucas Dupin
Browse files

wakeAndUnlock latency fixes

- Do not post to next frame (ag/214322930 already does it)
- Implement cancellation of event when biometrics fail
- Log end action when unlocking from a pulse

Fixes: 214322930
Test: atest BiometricUnlockControllerTest
Test: atest StatusBarKeyguardViewManagerTest
Change-Id: Ia7bd87f86822d072e7acf5ee99ebdc73f7135f41
parent 6bcc18f7
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
    private final MetricsLogger mMetricsLogger;
    private final AuthController mAuthController;
    private final StatusBarStateController mStatusBarStateController;
    private final LatencyTracker mLatencyTracker;

    private long mLastFpFailureUptimeMillis;
    private int mNumConsecutiveFpFailures;
@@ -281,7 +282,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
            AuthController authController,
            StatusBarStateController statusBarStateController,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            SessionTracker sessionTracker) {
            SessionTracker sessionTracker,
            LatencyTracker latencyTracker) {
        mContext = context;
        mPowerManager = powerManager;
        mShadeController = shadeController;
@@ -289,6 +291,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        mDozeParameters = dozeParameters;
        mUpdateMonitor.registerCallback(this);
        mMediaManager = notificationMediaManager;
        mLatencyTracker = latencyTracker;
        wakefulnessLifecycle.addObserver(mWakefulnessObserver);
        screenLifecycle.addObserver(mScreenObserver);

@@ -343,13 +346,13 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
    public void onBiometricAcquired(BiometricSourceType biometricSourceType) {
        Trace.beginSection("BiometricUnlockController#onBiometricAcquired");
        releaseBiometricWakeLock();
        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (LatencyTracker.isEnabled(mContext)) {
        if (isWakeAndUnlock()) {
            if (mLatencyTracker.isEnabled()) {
                int action = LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK;
                if (biometricSourceType == BiometricSourceType.FACE) {
                    action = LatencyTracker.ACTION_FACE_WAKE_AND_UNLOCK;
                }
                LatencyTracker.getInstance(mContext).onActionStart(action);
                mLatencyTracker.onActionStart(action);
            }
            mWakeLock = mPowerManager.newWakeLock(
                    PowerManager.PARTIAL_WAKE_LOCK, BIOMETRIC_WAKE_LOCK_NAME);
@@ -652,6 +655,14 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        Optional.ofNullable(BiometricUiEvent.FAILURE_EVENT_BY_SOURCE_TYPE.get(biometricSourceType))
                .ifPresent(event -> UI_EVENT_LOGGER.log(event, getSessionId()));

        if (mLatencyTracker.isEnabled()) {
            int action = LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK;
            if (biometricSourceType == BiometricSourceType.FACE) {
                action = LatencyTracker.ACTION_FACE_WAKE_AND_UNLOCK;
            }
            mLatencyTracker.onActionCancel(action);
        }

        if (biometricSourceType == BiometricSourceType.FINGERPRINT
                && mUpdateMonitor.isUdfpsSupported()) {
            long currUptimeMillis = SystemClock.uptimeMillis();
+8 −10
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.KeyguardViewController;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dreams.DreamOverlayStateController;
@@ -214,6 +213,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private final SysuiStatusBarStateController mStatusBarStateController;
    private final DockManager mDockManager;
    private final KeyguardUpdateMonitor mKeyguardUpdateManager;
    private final LatencyTracker mLatencyTracker;
    private KeyguardBypassController mBypassController;
    @Nullable private AlternateAuthInterceptor mAlternateAuthInterceptor;

@@ -246,7 +246,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            NotificationMediaManager notificationMediaManager,
            KeyguardBouncer.Factory keyguardBouncerFactory,
            KeyguardMessageAreaController.Factory keyguardMessageAreaFactory,
            Lazy<ShadeController> shadeController) {
            Lazy<ShadeController> shadeController,
            LatencyTracker latencyTracker) {
        mContext = context;
        mViewMediatorCallback = callback;
        mLockPatternUtils = lockPatternUtils;
@@ -262,6 +263,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        mKeyguardBouncerFactory = keyguardBouncerFactory;
        mKeyguardMessageAreaFactory = keyguardMessageAreaFactory;
        mShadeController = shadeController;
        mLatencyTracker = latencyTracker;
    }

    @Override
@@ -859,15 +861,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    }

    private void wakeAndUnlockDejank() {
        if (mBiometricUnlockController.getMode() == MODE_WAKE_AND_UNLOCK
                && LatencyTracker.isEnabled(mContext)) {
        if (mBiometricUnlockController.isWakeAndUnlock() && mLatencyTracker.isEnabled()) {
            BiometricSourceType type = mBiometricUnlockController.getBiometricType();
            DejankUtils.postAfterTraversal(() -> {
                    LatencyTracker.getInstance(mContext).onActionEnd(
                            type == BiometricSourceType.FACE
            mLatencyTracker.onActionEnd(type == BiometricSourceType.FACE
                            ? LatencyTracker.ACTION_FACE_WAKE_AND_UNLOCK
                            : LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK);
            });
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.testing.TestableLooper.RunWithLooper;
import android.testing.TestableResources;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
@@ -110,6 +111,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    private KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
    @Mock
    private SessionTracker mSessionTracker;
    @Mock
    private LatencyTracker mLatencyTracker;
    private BiometricUnlockController mBiometricUnlockController;

    @Before
@@ -133,7 +136,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                mMetricsLogger, mDumpManager, mPowerManager,
                mNotificationMediaManager, mWakefulnessLifecycle, mScreenLifecycle,
                mAuthController, mStatusBarStateController, mKeyguardUnlockAnimationController,
                mSessionTracker);
                mSessionTracker, mLatencyTracker);
        mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
        mBiometricUnlockController.setBiometricModeListener(mBiometricModeListener);
    }
+5 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.view.ViewGroup;

import androidx.test.filters.SmallTest;

import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardMessageArea;
import com.android.keyguard.KeyguardMessageAreaController;
@@ -100,6 +101,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    private ShadeController mShadeController;
    @Mock
    private DreamOverlayStateController mDreamOverlayStateController;
    @Mock
    private LatencyTracker mLatencyTracker;

    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;

@@ -127,7 +130,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
                mock(NotificationMediaManager.class),
                mKeyguardBouncerFactory,
                mKeyguardMessageAreaFactory,
                () -> mShadeController);
                () -> mShadeController,
                mLatencyTracker);
        mStatusBarKeyguardViewManager.registerStatusBar(
                mStatusBar,
                mNotificationPanelView,