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

Commit 095b7810 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Add logic for when to start the Udfps fp service"

parents ded47e0d c305f3fd
Loading
Loading
Loading
Loading
+39 −13
Original line number Diff line number Diff line
@@ -238,6 +238,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final boolean mIsAutomotive;
    private final AuthController mAuthController;
    private final StatusBarStateController mStatusBarStateController;
    private int mStatusBarState;
    private final StatusBarStateController.StateListener mStatusBarStateControllerListener =
            new StatusBarStateController.StateListener() {
        @Override
        public void onStateChanged(int newState) {
            mStatusBarState = newState;
            updateBiometricListeningState();
        }
    };

    HashMap<Integer, SimData> mSimDatas = new HashMap<>();
    HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();

@@ -247,7 +257,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mCredentialAttempted;
    private boolean mKeyguardGoingAway;
    private boolean mGoingToSleep;
    private boolean mBouncer;
    private boolean mBouncer; // true if bouncerIsOrWillBeShowing
    private boolean mAuthInterruptActive;
    private boolean mNeedsSlowUnlockTransition;
    private boolean mHasLockscreenWallpaper;
@@ -1595,6 +1605,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mBroadcastDispatcher = broadcastDispatcher;
        mRingerModeTracker = ringerModeTracker;
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(mStatusBarStateControllerListener);
        mStatusBarState = mStatusBarStateController.getState();
        mLockPatternUtils = lockPatternUtils;
        mAuthController = authController;
        dumpManager.registerDumpable(getClass().getName(), this);
@@ -1905,7 +1917,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            return;
        }

        boolean shouldListenForFingerprint = shouldListenForFingerprint();
        boolean shouldListenForFingerprint =
                isUdfpsEnrolled() ? shouldListenForUdfps() : shouldListenForFingerprint();
        boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
                || mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
        if (runningOrRestarting && !shouldListenForFingerprint) {
@@ -2002,12 +2015,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return shouldListen;
    }

    @VisibleForTesting
    boolean shouldListenForUdfps() {
        return shouldListenForFingerprint()
                && !mBouncer
                && mStatusBarState != StatusBarState.SHADE_LOCKED
                && mStatusBarState != StatusBarState.FULLSCREEN_USER_SWITCHER
                && mStrongAuthTracker.hasUserAuthenticatedSinceBoot();
    }

    /**
     * If face auth is allows to scan on this exact moment.
     */
    public boolean shouldListenForFace() {
        final boolean statusBarShadeLocked =
                mStatusBarStateController.getState() == StatusBarState.SHADE_LOCKED;
        final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED;
        final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep
                && !statusBarShadeLocked;
        final int user = getCurrentUser();
@@ -2593,13 +2614,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     *
     * @see #sendKeyguardBouncerChanged(boolean)
     */
    private void handleKeyguardBouncerChanged(int bouncer) {
    private void handleKeyguardBouncerChanged(int bouncerVisible) {
        Assert.isMainThread();
        if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncer + ")");
        boolean isBouncer = (bouncer == 1);
        mBouncer = isBouncer;
        if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncerVisible + ")");
        mBouncer = bouncerVisible == 1;

        if (isBouncer) {
        if (mBouncer) {
            // If the bouncer is shown, always clear this flag. This can happen in the following
            // situations: 1) Default camera with SHOW_WHEN_LOCKED is not chosen yet. 2) Secure
            // camera requests dismiss keyguard (tapping on photos for example). When these happen,
@@ -2612,7 +2632,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onKeyguardBouncerChanged(isBouncer);
                cb.onKeyguardBouncerChanged(mBouncer);
            }
        }
        updateBiometricListeningState();
@@ -2745,10 +2765,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    /**
     * @see #handleKeyguardBouncerChanged(int)
     */
    public void sendKeyguardBouncerChanged(boolean showingBouncer) {
        if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + showingBouncer + ")");
    public void sendKeyguardBouncerChanged(boolean bouncerIsOrWillBeShowing) {
        if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + bouncerIsOrWillBeShowing + ")");
        Message message = mHandler.obtainMessage(MSG_KEYGUARD_BOUNCER_CHANGED);
        message.arg1 = showingBouncer ? 1 : 0;
        message.arg1 = bouncerIsOrWillBeShowing ? 1 : 0;
        message.sendToTarget();
    }

@@ -3081,6 +3101,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            pw.println("    strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
            pw.println("    trustManaged=" + getUserTrustIsManaged(userId));
            pw.println("    udfpsEnrolled=" + isUdfpsEnrolled());
            if (isUdfpsEnrolled()) {
                pw.println("        shouldListenForUdfps=" + shouldListenForUdfps());
                pw.println("        bouncerVisible=" + mBouncer);
                pw.println("        mStatusBarState="
                        + StatusBarState.toShortString(mStatusBarState));
            }
        }
        if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
            final int userId = ActivityManager.getCurrentUser();
+2 −1
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ public class KeyguardUpdateMonitorCallback {

    /**
     * Called when the keyguard enters or leaves bouncer mode.
     * @param bouncer if true, keyguard is now in bouncer mode.
     * @param bouncer if true, keyguard is showing the bouncer or transitioning from/to bouncer
     *                mode.
     */
    public void onKeyguardBouncerChanged(boolean bouncer) { }

+1 −31
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.KeyguardBouncer;

import java.util.ArrayList;
import java.util.List;
@@ -68,7 +67,7 @@ import javax.inject.Provider;
 */
@SysUISingleton
public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        AuthDialogCallback, DozeReceiver, KeyguardBouncer.BouncerExpansionCallback {
        AuthDialogCallback, DozeReceiver {

    private static final String TAG = "AuthController";
    private static final boolean DEBUG = true;
@@ -460,35 +459,6 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        mCurrentDialog = null;
    }

    /** See {@link KeyguardBouncer.BouncerExpansionCallback#onFullyShown}. */
    @Override
    public void onFullyShown() {
        if (mUdfpsController != null) {
            mUdfpsController.setBouncerVisibility(true);
        }
    }

    /** See {@link KeyguardBouncer.BouncerExpansionCallback#onStartingToHide}. */
    @Override
    public void onStartingToHide() {
    }

    /** See {@link KeyguardBouncer.BouncerExpansionCallback#onStartingToShow}. */
    @Override
    public void onStartingToShow() {
        if (mUdfpsController != null) {
            mUdfpsController.setBouncerVisibility(true);
        }
    }

    /** See {@link KeyguardBouncer.BouncerExpansionCallback#onFullyHidden}. */
    @Override
    public void onFullyHidden() {
        if (mUdfpsController != null) {
            mUdfpsController.setBouncerVisibility(false);
        }
    }

   /**
     * Whether the passed userId has enrolled UDFPS.
     */
+1 −16
Original line number Diff line number Diff line
@@ -107,8 +107,6 @@ class UdfpsController implements DozeReceiver {
    private boolean mIsOverlayShowing;
    // Indicates whether the overlay has been requested.
    private boolean mIsOverlayRequested;
    // Indicates whether the bouncer is showing. When it is showing, the overlay needs to be hidden.
    private boolean mIsBouncerShowing;

    // The fingerprint AOD trigger doesn't provide an ACTION_UP/ACTION_CANCEL event to tell us when
    // to turn off high brightness mode. To get around this limitation, the state of the AOD
@@ -260,21 +258,8 @@ class UdfpsController implements DozeReceiver {
        updateOverlay();
    }

    /**
     * Call when the visibility of the bouncer changes.
     *
     * @param isShowing Whether or not the bouncer is showing
     */
    void setBouncerVisibility(boolean isShowing) {
        if (isShowing == mIsBouncerShowing) {
            return;
        }
        mIsBouncerShowing = isShowing;
        updateOverlay();
    }

    private void updateOverlay() {
        if (mIsOverlayRequested && !mIsBouncerShowing) {
        if (mIsOverlayRequested) {
            showUdfpsOverlay();
        } else {
            hideUdfpsOverlay();
+1 −14
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.ViewMediatorCallback;
import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.DejankUtils;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.dagger.qualifiers.RootView;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.FalsingManager;
@@ -70,7 +69,6 @@ public class KeyguardBouncer {
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final Handler mHandler;
    private final List<BouncerExpansionCallback> mExpansionCallbacks = new ArrayList<>();
    private final AuthController mAuthController;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final KeyguardStateController mKeyguardStateController;
    private final KeyguardSecurityModel mKeyguardSecurityModel;
@@ -104,7 +102,6 @@ public class KeyguardBouncer {
            ViewGroup container,
            DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager,
            BouncerExpansionCallback expansionCallback,
            AuthController authController,
            KeyguardStateController keyguardStateController,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            KeyguardBypassController keyguardBypassController, Handler handler,
@@ -123,8 +120,6 @@ public class KeyguardBouncer {
        mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback);
        mKeyguardBypassController = keyguardBypassController;
        mExpansionCallbacks.add(expansionCallback);
        mExpansionCallbacks.add(authController);
        mAuthController = authController;
    }

    public void show(boolean resetSecuritySelection) {
@@ -297,11 +292,6 @@ public class KeyguardBouncer {
        mIsScrimmed = false;
        mFalsingManager.onBouncerHidden();
        mCallback.onBouncerVisiblityChanged(false /* shown */);
        // TODO(b/165257355): `mAuthController.onFullyHidden` should be `dispatchFullyHidden()`
        // But, it is causing the UDFPS icon to disappear after SystemUI restarts. I guess the
        // ExpansionCallback from StatusBarKeyguardViewManager can't handle the call to
        // onFullyHidden after a restart.
        mAuthController.onFullyHidden();
        cancelShowRunnable();
        if (mKeyguardViewController != null) {
            mKeyguardViewController.cancelDismissAction();
@@ -552,7 +542,6 @@ public class KeyguardBouncer {
        private final ViewMediatorCallback mCallback;
        private final DismissCallbackRegistry mDismissCallbackRegistry;
        private final FalsingManager mFalsingManager;
        private final AuthController mAuthController;
        private final KeyguardStateController mKeyguardStateController;
        private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
        private final KeyguardBypassController mKeyguardBypassController;
@@ -563,7 +552,6 @@ public class KeyguardBouncer {
        @Inject
        public Factory(Context context, ViewMediatorCallback callback,
                DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager,
                AuthController authController,
                KeyguardStateController keyguardStateController,
                KeyguardUpdateMonitor keyguardUpdateMonitor,
                KeyguardBypassController keyguardBypassController, Handler handler,
@@ -573,7 +561,6 @@ public class KeyguardBouncer {
            mCallback = callback;
            mDismissCallbackRegistry = dismissCallbackRegistry;
            mFalsingManager = falsingManager;
            mAuthController = authController;
            mKeyguardStateController = keyguardStateController;
            mKeyguardUpdateMonitor = keyguardUpdateMonitor;
            mKeyguardBypassController = keyguardBypassController;
@@ -586,7 +573,7 @@ public class KeyguardBouncer {
                BouncerExpansionCallback expansionCallback) {
            return new KeyguardBouncer(mContext, mCallback, container,
                    mDismissCallbackRegistry, mFalsingManager, expansionCallback,
                    mAuthController, mKeyguardStateController, mKeyguardUpdateMonitor,
                    mKeyguardStateController, mKeyguardUpdateMonitor,
                    mKeyguardBypassController, mHandler, mKeyguardSecurityModel,
                    mKeyguardBouncerComponentFactory);
        }
Loading