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

Commit 3d19b614 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use cached KeyguardUpdateMonitor#isUdfpsEnrolled"

parents 49ae1cbd 3163ffad
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final DevicePolicyManager mDevicePolicyManager;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private boolean mLogoutEnabled;
    // cached value to avoid IPCs
    private boolean mIsUdfpsEnrolled;
    // If the user long pressed the lock icon, disabling face auth for the current session.
    private boolean mLockIconPressed;
    private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -1857,7 +1859,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private void updateLockScreenMode() {
        mLockScreenMode = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.SHOW_NEW_LOCKSCREEN, mAuthController.isUdfpsEnrolled() ? 1 : 0);
                Settings.Global.SHOW_NEW_LOCKSCREEN,
                isUdfpsEnrolled() ? 1 : 0);
    }

    private void updateUdfpsEnrolled(int userId) {
        mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId);
    }
    public boolean isUdfpsEnrolled() {
        return mIsUdfpsEnrolled;
    }

    private final UserSwitchObserver mUserSwitchObserver = new UserSwitchObserver() {
@@ -2098,6 +2108,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
        if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
        int userId = getCurrentUser();
        updateUdfpsEnrolled(userId);
        if (isUnlockWithFingerprintPossible(userId)) {
            if (mFingerprintCancelSignal != null) {
                mFingerprintCancelSignal.cancel();
@@ -3069,6 +3080,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    + " expected=" + (shouldListenForFingerprint() ? 1 : 0));
            pw.println("    strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
            pw.println("    trustManaged=" + getUserTrustIsManaged(userId));
            pw.println("    udfpsEnrolled=" + isUdfpsEnrolled());
        }
        if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
            final int userId = ActivityManager.getCurrentUser();
+22 −14
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ 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;

import javax.inject.Inject;
@@ -81,6 +82,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,

    @Nullable private final List<FingerprintSensorPropertiesInternal> mFpProps;
    @Nullable private final List<FaceSensorPropertiesInternal> mFaceProps;
    @Nullable private final List<FingerprintSensorPropertiesInternal> mUdfpsProps;

    // TODO: These should just be saved from onSaveState
    private SomeArgs mCurrentDialogArgs;
@@ -314,6 +316,16 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                : null;
        mFaceProps = mFaceManager != null ? mFaceManager.getSensorPropertiesInternal() : null;

        List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
        if (mFpProps != null) {
            for (FingerprintSensorPropertiesInternal props : mFpProps) {
                if (props.isAnyUdfpsType()) {
                    udfpsProps.add(props);
                }
            }
        }
        mUdfpsProps = !udfpsProps.isEmpty() ? udfpsProps : null;

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

@@ -326,15 +338,9 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        mCommandQueue.addCallback(this);
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);

        if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
            final List<FingerprintSensorPropertiesInternal> fingerprintSensorProperties =
                    mFingerprintManager.getSensorPropertiesInternal();
            for (FingerprintSensorPropertiesInternal props : fingerprintSensorProperties) {
                if (props.isAnyUdfpsType()) {
        if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()
                && mUdfpsProps != null) {
            mUdfpsController = mUdfpsControllerFactory.get();
                    break;
                }
            }
        }

        try {
@@ -484,12 +490,14 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    }

   /**
     * Whether the current user has a UDFP enrolled.
     * Whether the passed userId has enrolled UDFPS.
     */
    public boolean isUdfpsEnrolled() {
        // TODO: (b/171392825) right now only checks whether the UDFPS sensor exists on this device
        //  but not whether user has enrolled or not
        return mUdfpsController != null;
    public boolean isUdfpsEnrolled(int userId) {
        if (mUdfpsController == null) {
            return false;
        }

        return mFingerprintManager.hasEnrolledTemplatesForAnySensor(userId, mUdfpsProps);
    }

    private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.UiEventLoggerImpl;
import com.android.internal.logging.nano.MetricsProto;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.plugins.SensorManagerPlugin;
import com.android.systemui.statusbar.phone.DozeParameters;
@@ -156,7 +157,7 @@ public class DozeSensors {
                        findSensorWithType(config.udfpsLongPressSensorType()),
                        "doze_pulse_on_auth",
                        true /* settingDef */,
                        authController.isUdfpsEnrolled() /* configured */,
                        authController.isUdfpsEnrolled(KeyguardUpdateMonitor.getCurrentUser()),
                        DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS,
                        true /* reports touch coordinates */,
                        true /* touchscreen */,
+2 −6
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager;
@@ -77,7 +76,6 @@ public class LockscreenLockIconController {
    private final KeyguardStateController mKeyguardStateController;
    private final Resources mResources;
    private final HeadsUpManagerPhone mHeadsUpManagerPhone;
    private final AuthController mAuthController;
    private boolean mKeyguardShowing;
    private boolean mKeyguardJustShown;
    private boolean mBlockUpdates;
@@ -326,8 +324,7 @@ public class LockscreenLockIconController {
            @Nullable DockManager dockManager,
            KeyguardStateController keyguardStateController,
            @Main Resources resources,
            HeadsUpManagerPhone headsUpManagerPhone,
            AuthController authController) {
            HeadsUpManagerPhone headsUpManagerPhone) {
        mLockscreenGestureLogger = lockscreenGestureLogger;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mLockPatternUtils = lockPatternUtils;
@@ -342,7 +339,6 @@ public class LockscreenLockIconController {
        mKeyguardStateController = keyguardStateController;
        mResources = resources;
        mHeadsUpManagerPhone = headsUpManagerPhone;
        mAuthController = authController;

        mKeyguardIndicationController.setLockIconController(this);
    }
@@ -508,7 +504,7 @@ public class LockscreenLockIconController {
     * @return true if the visibility changed
     */
    private boolean updateIconVisibility() {
        if (mAuthController.isUdfpsEnrolled()) {
        if (mKeyguardUpdateMonitor.isUdfpsEnrolled()) {
            boolean changed = mLockIcon.getVisibility() == GONE;
            mLockIcon.setVisibility(GONE);
            return changed;
+2 −2
Original line number Diff line number Diff line
@@ -873,7 +873,7 @@ public class NotificationPanelViewController extends PanelViewController {
                    clockPreferredY, hasCustomClock(),
                    hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
                    bypassEnabled, getUnlockedStackScrollerPadding(),
                    mAuthController.isUdfpsEnrolled());
                    mUpdateMonitor.isUdfpsEnrolled());
            mClockPositionAlgorithm.run(mClockPositionResult);
            mKeyguardStatusViewController.updatePosition(
                    mClockPositionResult.clockX, mClockPositionResult.clockY, animateClock);
@@ -914,7 +914,7 @@ public class NotificationPanelViewController extends PanelViewController {
                        - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)
                        - mKeyguardStatusViewController.getLogoutButtonHeight();

        if (mAuthController.isUdfpsEnrolled()) {
        if (mUpdateMonitor.isUdfpsEnrolled()) {
            availableSpace = mNotificationStackScrollLayoutController.getHeight()
                    - minPadding - shelfSize
                    - (mStatusBar.getDisplayHeight() - mAuthController.getUdfpsRegion().top);
Loading