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

Commit 8adb30cc authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Add ability to simulate fingerprint wake-and-unlock for testing

We are testing the path from onAcquired until the fading out animation
starts using a broadcast.

Note that this is *not* a backdoor as this only works if the no
unlock credential is set for the current user.

Change-Id: I13618f6ce4aae24744fa3c5ba222cfcd9d9df1b6
parent e05256e2
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -39,12 +39,25 @@ public class LatencyTracker {

    private static final String TAG = "LatencyTracker";

    /**
     * Time it takes until the first frame of the notification panel to be displayed while expanding
     */
    public static final int ACTION_EXPAND_PANEL = 0;

    /**
     * Time it takes until the first frame of recents is drawn after invoking it with the button.
     */
    public static final int ACTION_TOGGLE_RECENTS = 1;

    /**
     * Time between we get a fingerprint acquired signal until we start with the unlock animation
     */
    public static final int ACTION_FINGERPRINT_WAKE_AND_UNLOCK = 2;

    private static final String[] NAMES = new String[] {
            "expand panel",
            "toggle recents" };
            "toggle recents",
            "fingerprint wake-and-unlock" };

    private static LatencyTracker sLatencyTracker;

+31 −2
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

package com.android.systemui.statusbar.phone;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
@@ -26,6 +30,7 @@ import android.util.Log;
import com.android.keyguard.KeyguardConstants;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.LatencyTracker;
import com.android.systemui.keyguard.KeyguardViewMediator;

/**
@@ -37,6 +42,8 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
    private static final boolean DEBUG_FP_WAKELOCK = KeyguardConstants.DEBUG_FP_WAKELOCK;
    private static final long FINGERPRINT_WAKELOCK_TIMEOUT_MS = 15 * 1000;
    private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock";
    private static final String ACTION_FINGERPRINT_WAKE_FAKE =
            "com.android.systemui.ACTION_FINGERPRINT_WAKE_FAKE";

    /**
     * Mode in which we don't need to wake up the device when we get a fingerprint.
@@ -94,6 +101,8 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
    private KeyguardViewMediator mKeyguardViewMediator;
    private ScrimController mScrimController;
    private PhoneStatusBar mPhoneStatusBar;
    private final UnlockMethodCache mUnlockMethodCache;
    private final Context mContext;
    private boolean mGoingToSleep;
    private int mPendingAuthenticatedUserId = -1;

@@ -102,7 +111,9 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
            DozeScrimController dozeScrimController,
            KeyguardViewMediator keyguardViewMediator,
            ScrimController scrimController,
            PhoneStatusBar phoneStatusBar) {
            PhoneStatusBar phoneStatusBar,
            UnlockMethodCache unlockMethodCache) {
        mContext = context;
        mPowerManager = context.getSystemService(PowerManager.class);
        mUpdateMonitor = KeyguardUpdateMonitor.getInstance(context);
        mUpdateMonitor.registerCallback(this);
@@ -111,6 +122,15 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
        mKeyguardViewMediator = keyguardViewMediator;
        mScrimController = scrimController;
        mPhoneStatusBar = phoneStatusBar;
        mUnlockMethodCache = unlockMethodCache;
        if (Build.IS_DEBUGGABLE) {
            context.registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    fakeWakeAndUnlock();
                }
            }, new IntentFilter(ACTION_FINGERPRINT_WAKE_FAKE));
        }
    }

    public void setStatusBarKeyguardViewManager(
@@ -139,11 +159,20 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
        }
    }

    public void fakeWakeAndUnlock() {
        onFingerprintAcquired();
        onFingerprintAuthenticated(KeyguardUpdateMonitor.getCurrentUser());
    }

    @Override
    public void onFingerprintAcquired() {
        Trace.beginSection("FingerprintUnlockController#onFingerprintAcquired");
        releaseFingerprintWakeLock();
        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (LatencyTracker.isEnabled(mContext)) {
                LatencyTracker.getInstance(mContext).onActionStart(
                        LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK);
            }
            mWakeLock = mPowerManager.newWakeLock(
                    PowerManager.PARTIAL_WAKE_LOCK, FINGERPRINT_WAKE_LOCK_NAME);
            Trace.beginSection("acquiring wake-and-unlock");
@@ -263,7 +292,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
                return MODE_ONLY_WAKE;
            } else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
                return MODE_WAKE_AND_UNLOCK_PULSING;
            } else if (unlockingAllowed) {
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
                return MODE_WAKE_AND_UNLOCK;
            } else {
                return MODE_SHOW_BOUNCER;
+1 −1
Original line number Diff line number Diff line
@@ -1233,7 +1233,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        KeyguardViewMediator keyguardViewMediator = getComponent(KeyguardViewMediator.class);
        mFingerprintUnlockController = new FingerprintUnlockController(mContext,
                mStatusBarWindowManager, mDozeScrimController, keyguardViewMediator,
                mScrimController, this);
                mScrimController, this, UnlockMethodCache.getInstance(mContext));
        mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
                getBouncerContainer(), mStatusBarWindowManager, mScrimController,
                mFingerprintUnlockController);
+11 −4
Original line number Diff line number Diff line
@@ -30,11 +30,14 @@ import android.view.WindowManagerGlobal;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.DejankUtils;
import com.android.systemui.LatencyTracker;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.RemoteInputController;

import static com.android.keyguard.KeyguardHostView.OnDismissAction;
import static com.android.systemui.statusbar.phone.FingerprintUnlockController.*;

/**
 * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back
@@ -323,8 +326,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                }
            });
        } else {
            if (mFingerprintUnlockController.getMode()
                    == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING) {
            if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK_PULSING) {
                mFingerprintUnlockController.startKeyguardFadingAway();
                mPhoneStatusBar.setKeyguardFadingAway(startTime, 0, 240);
                mStatusBarWindowManager.setKeyguardFadingAway(true);
@@ -341,8 +343,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                boolean staying = mPhoneStatusBar.hideKeyguard();
                if (!staying) {
                    mStatusBarWindowManager.setKeyguardFadingAway(true);
                    if (mFingerprintUnlockController.getMode()
                            == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK) {
                    if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK) {
                        if (!mScreenTurnedOn) {
                            mDeferScrimFadeOut = true;
                        } else {
@@ -396,6 +397,12 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "Fading out", 0);
            }
        }, skipFirstFrame);
        if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK
                && LatencyTracker.isEnabled(mContext)) {
            DejankUtils.postAfterTraversal(() ->
                    LatencyTracker.getInstance(mContext).onActionEnd(
                            LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK));
        }
    }

    private void executeAfterKeyguardGoneAction() {