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

Commit 35d68aa1 authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "On devices with udfps, hint to press to open" into sc-dev am: 555c174a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15373461

Change-Id: I89082fadd6ea13136c4a160298b975ae505ae933
parents 4f4d4b56 555c174a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2067,6 +2067,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return mIsUdfpsEnrolled;
    }

    /**
     * @return if udfps is available on this device. will return true even if the user hasn't
     * enrolled udfps.
     */
    public boolean isUdfpsAvailable() {
        return mAuthController.getUdfpsProps() != null
                && !mAuthController.getUdfpsProps().isEmpty();
    }

    /**
     * @return true if there's at least one face enrolled
     */
+29 −12
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ import com.android.systemui.keyguard.KeyguardIndication;
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -100,7 +101,7 @@ public class KeyguardIndicationController {
    private static final boolean DEBUG_CHARGING_SPEED = false;

    private static final int MSG_HIDE_TRANSIENT = 1;
    private static final int MSG_SWIPE_UP_TO_UNLOCK = 2;
    private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2;
    private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300;
    private static final float BOUNCE_ANIMATION_FINAL_Y = 0f;

@@ -121,6 +122,7 @@ public class KeyguardIndicationController {
    private final LockPatternUtils mLockPatternUtils;
    private final IActivityManager mIActivityManager;
    private final FalsingManager mFalsingManager;
    private final KeyguardBypassController mKeyguardBypassController;

    protected KeyguardIndicationRotateTextViewController mRotateTextViewController;
    private BroadcastReceiver mBroadcastReceiver;
@@ -175,7 +177,8 @@ public class KeyguardIndicationController {
            @Main DelayableExecutor executor,
            FalsingManager falsingManager,
            LockPatternUtils lockPatternUtils,
            IActivityManager iActivityManager) {
            IActivityManager iActivityManager,
            KeyguardBypassController keyguardBypassController) {
        mContext = context;
        mBroadcastDispatcher = broadcastDispatcher;
        mDevicePolicyManager = devicePolicyManager;
@@ -191,6 +194,7 @@ public class KeyguardIndicationController {
        mLockPatternUtils = lockPatternUtils;
        mIActivityManager = iActivityManager;
        mFalsingManager = falsingManager;
        mKeyguardBypassController = keyguardBypassController;

    }

@@ -593,7 +597,7 @@ public class KeyguardIndicationController {
        mTransientIndication = transientIndication;
        mHideTransientMessageOnScreenOff = hideOnScreenOff && transientIndication != null;
        mHandler.removeMessages(MSG_HIDE_TRANSIENT);
        mHandler.removeMessages(MSG_SWIPE_UP_TO_UNLOCK);
        mHandler.removeMessages(MSG_SHOW_ACTION_TO_UNLOCK);
        if (mDozing && !TextUtils.isEmpty(mTransientIndication)) {
            // Make sure this doesn't get stuck and burns in. Acquire wakelock until its cleared.
            mWakeLock.setAcquired(true);
@@ -785,29 +789,37 @@ public class KeyguardIndicationController {
        public void handleMessage(Message msg) {
            if (msg.what == MSG_HIDE_TRANSIENT) {
                hideTransientIndication();
            } else if (msg.what == MSG_SWIPE_UP_TO_UNLOCK) {
                showSwipeUpToUnlock();
            } else if (msg.what == MSG_SHOW_ACTION_TO_UNLOCK) {
                showActionToUnlock();
            }
        }
    };

    private void showSwipeUpToUnlock() {
    /**
     * Show message on the keyguard for how the user can unlock/enter their device.
     */
    public void showActionToUnlock() {
        if (mDozing) {
            return;
        }

        if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
            if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) {
                return; // udfps affordance is highlighted, no need to surface face auth error
            } else {
                return; // udfps affordance is highlighted, no need to show action to unlock
            } else if (mKeyguardUpdateMonitor.isFaceEnrolled()) {
                String message = mContext.getString(R.string.keyguard_retry);
                mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState);
            }
        } else if (mKeyguardUpdateMonitor.isScreenOn()) {
            if (mKeyguardUpdateMonitor.isUdfpsAvailable()) {
                showTransientIndication(mContext.getString(R.string.keyguard_unlock_press),
                        false /* isError */, true /* hideOnScreenOff */);
            } else {
                showTransientIndication(mContext.getString(R.string.keyguard_unlock),
                        false /* isError */, true /* hideOnScreenOff */);
            }
        }
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("KeyguardIndicationController:");
@@ -894,7 +906,7 @@ public class KeyguardIndicationController {
                showTransientIndication(helpString, false /* isError */, showSwipeToUnlock);
            }
            if (showSwipeToUnlock) {
                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SWIPE_UP_TO_UNLOCK),
                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_ACTION_TO_UNLOCK),
                        TRANSIENT_BIOMETRIC_ERROR_TIMEOUT);
            }
        }
@@ -928,7 +940,7 @@ public class KeyguardIndicationController {
                    );
                } else {
                    // suggest swiping up to unlock (try face auth again or swipe up to bouncer)
                    showSwipeUpToUnlock();
                    showActionToUnlock();
                }
            } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
                mStatusBarKeyguardViewManager.showBouncerMessage(errString, mInitialTextColorState);
@@ -1010,6 +1022,11 @@ public class KeyguardIndicationController {
                boolean isStrongBiometric) {
            super.onBiometricAuthenticated(userId, biometricSourceType, isStrongBiometric);
            mHandler.sendEmptyMessage(MSG_HIDE_TRANSIENT);

            if (biometricSourceType == BiometricSourceType.FACE
                    && !mKeyguardBypassController.canBypass()) {
                mHandler.sendEmptyMessage(MSG_SHOW_ACTION_TO_UNLOCK);
            }
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -3984,7 +3984,7 @@ public class StatusBar extends SystemUI implements DemoMode,

    public void onUnlockHintStarted() {
        mFalsingCollector.onUnlockHintStarted();
        mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock);
        mKeyguardIndicationController.showActionToUnlock();
    }

    public void onHintFinished() {
+6 −1
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import com.android.systemui.keyguard.KeyguardIndication;
import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
@@ -146,6 +147,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
    private LockPatternUtils mLockPatternUtils;
    @Mock
    private IActivityManager mIActivityManager;
    @Mock
    private KeyguardBypassController mKeyguardBypassController;
    @Captor
    private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
    @Captor
@@ -216,7 +219,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
        mController = new KeyguardIndicationController(mContext, mWakeLockBuilder,
                mKeyguardStateController, mStatusBarStateController, mKeyguardUpdateMonitor,
                mDockManager, mBroadcastDispatcher, mDevicePolicyManager, mIBatteryStats,
                mUserManager, mExecutor, mFalsingManager, mLockPatternUtils, mIActivityManager);
                mUserManager, mExecutor, mFalsingManager, mLockPatternUtils, mIActivityManager,
                mKeyguardBypassController);
        mController.init();
        mController.setIndicationArea(mIndicationArea);
        verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
@@ -507,6 +511,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
        createController();
        String message = mContext.getString(R.string.keyguard_retry);
        when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true);
        when(mKeyguardUpdateMonitor.isFaceEnrolled()).thenReturn(true);

        mController.setVisible(true);
        mController.getKeyguardCallback().onBiometricError(FaceManager.FACE_ERROR_TIMEOUT,