diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardIndicationRotateTextViewController.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardIndicationRotateTextViewController.java index f84a5e39163f8..9235e10209d44 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardIndicationRotateTextViewController.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardIndicationRotateTextViewController.java @@ -375,7 +375,7 @@ public class KeyguardIndicationRotateTextViewController extends public static final int INDICATION_TYPE_ALIGNMENT = 4; public static final int INDICATION_TYPE_TRANSIENT = 5; public static final int INDICATION_TYPE_TRUST = 6; - public static final int INDICATION_TYPE_RESTING = 7; + public static final int INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE = 7; public static final int INDICATION_TYPE_USER_LOCKED = 8; public static final int INDICATION_TYPE_REVERSE_CHARGING = 10; public static final int INDICATION_TYPE_BIOMETRIC_MESSAGE = 11; @@ -390,7 +390,7 @@ public class KeyguardIndicationRotateTextViewController extends INDICATION_TYPE_ALIGNMENT, INDICATION_TYPE_TRANSIENT, INDICATION_TYPE_TRUST, - INDICATION_TYPE_RESTING, + INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE, INDICATION_TYPE_USER_LOCKED, INDICATION_TYPE_REVERSE_CHARGING, INDICATION_TYPE_BIOMETRIC_MESSAGE, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index d21f2abea5132..0f27420e22b03 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -36,7 +36,7 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_LOGOUT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_OWNER_INFO; -import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING; +import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED; import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON; @@ -161,7 +161,7 @@ public class KeyguardIndicationController { private BroadcastReceiver mBroadcastReceiver; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private String mRestingIndication; + private String mPersistentUnlockMessage; private String mAlignmentIndication; private CharSequence mTrustGrantedIndication; private CharSequence mTransientIndication; @@ -379,7 +379,7 @@ public class KeyguardIndicationController { updateLockScreenTrustMsg(userId, getTrustGrantedIndication(), getTrustManagedIndication()); updateLockScreenAlignmentMsg(); updateLockScreenLogoutView(); - updateLockScreenRestingMsg(); + updateLockScreenPersistentUnlockMsg(); } private void updateOrganizedOwnedDevice() { @@ -485,7 +485,8 @@ public class KeyguardIndicationController { } private void updateLockScreenUserLockedMsg(int userId) { - if (!mKeyguardUpdateMonitor.isUserUnlocked(userId)) { + if (!mKeyguardUpdateMonitor.isUserUnlocked(userId) + || mKeyguardUpdateMonitor.isEncryptedOrLockdown(userId)) { mRotateTextViewController.updateIndication( INDICATION_TYPE_USER_LOCKED, new KeyguardIndication.Builder() @@ -590,18 +591,17 @@ public class KeyguardIndicationController { } } - private void updateLockScreenRestingMsg() { - if (!TextUtils.isEmpty(mRestingIndication) - && !mRotateTextViewController.hasIndications()) { + private void updateLockScreenPersistentUnlockMsg() { + if (!TextUtils.isEmpty(mPersistentUnlockMessage)) { mRotateTextViewController.updateIndication( - INDICATION_TYPE_RESTING, + INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE, new KeyguardIndication.Builder() - .setMessage(mRestingIndication) + .setMessage(mPersistentUnlockMessage) .setTextColor(mInitialTextColorState) .build(), - false); + true); } else { - mRotateTextViewController.hideIndication(INDICATION_TYPE_RESTING); + mRotateTextViewController.hideIndication(INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE); } } @@ -684,11 +684,8 @@ public class KeyguardIndicationController { } } - /** - * Sets the indication that is shown if nothing else is showing. - */ - public void setRestingIndication(String restingIndication) { - mRestingIndication = restingIndication; + private void setPersistentUnlockMessage(String persistentUnlockMessage) { + mPersistentUnlockMessage = persistentUnlockMessage; updateDeviceEntryIndication(false); } @@ -1122,6 +1119,9 @@ public class KeyguardIndicationController { public void onLockedOutStateChanged(BiometricSourceType biometricSourceType) { if (biometricSourceType == FACE && !mKeyguardUpdateMonitor.isFaceLockedOut()) { mFaceLockedOutThisAuthSession = false; + } else if (biometricSourceType == FINGERPRINT) { + setPersistentUnlockMessage(mKeyguardUpdateMonitor.isFingerprintLockedOut() + ? mContext.getString(R.string.keyguard_unlock) : ""); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java index a64722a3c4bcb..c280ec8c4ec81 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -32,10 +32,9 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_LOGOUT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_OWNER_INFO; -import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING; +import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRANSIENT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST; -import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED; import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_OFF; import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON; import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_TURNING_ON; @@ -830,31 +829,6 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mContext.getString(R.string.keyguard_suggest_fingerprint)); } - @Test - public void updateMonitor_listenerUpdatesIndication() { - createController(); - String restingIndication = "Resting indication"; - reset(mKeyguardUpdateMonitor); - - mController.setVisible(true); - verifyIndicationMessage(INDICATION_TYPE_USER_LOCKED, - mContext.getString(com.android.internal.R.string.lockscreen_storage_locked)); - - reset(mRotateTextViewController); - when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true); - when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true); - mController.setRestingIndication(restingIndication); - verifyHideIndication(INDICATION_TYPE_USER_LOCKED); - verifyIndicationMessage(INDICATION_TYPE_RESTING, restingIndication); - - reset(mRotateTextViewController); - reset(mKeyguardUpdateMonitor); - when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true); - when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false); - mKeyguardStateControllerCallback.onUnlockedChanged(); - verifyIndicationMessage(INDICATION_TYPE_RESTING, restingIndication); - } - @Test public void onRefreshBatteryInfo_computesChargingTime() throws RemoteException { createController(); @@ -1490,6 +1464,44 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { verifyIndicationShown(INDICATION_TYPE_BIOMETRIC_MESSAGE, "second lockout"); } + @Test + public void onFpLockoutStateChanged_whenFpIsLockedOut_showsPersistentMessage() { + createController(); + mController.setVisible(true); + when(mKeyguardUpdateMonitor.isFingerprintLockedOut()).thenReturn(true); + + mKeyguardUpdateMonitorCallback.onLockedOutStateChanged(BiometricSourceType.FINGERPRINT); + + verifyIndicationShown(INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE, + mContext.getString(R.string.keyguard_unlock)); + } + + @Test + public void onFpLockoutStateChanged_whenFpIsNotLockedOut_showsPersistentMessage() { + createController(); + mController.setVisible(true); + clearInvocations(mRotateTextViewController); + when(mKeyguardUpdateMonitor.isFingerprintLockedOut()).thenReturn(false); + + mKeyguardUpdateMonitorCallback.onLockedOutStateChanged(BiometricSourceType.FINGERPRINT); + + verifyHideIndication(INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE); + } + + @Test + public void onVisibilityChange_showsPersistentMessage_ifFpIsLockedOut() { + createController(); + mController.setVisible(false); + when(mKeyguardUpdateMonitor.isFingerprintLockedOut()).thenReturn(true); + mKeyguardUpdateMonitorCallback.onLockedOutStateChanged(BiometricSourceType.FINGERPRINT); + clearInvocations(mRotateTextViewController); + + mController.setVisible(true); + + verifyIndicationShown(INDICATION_TYPE_PERSISTENT_UNLOCK_MESSAGE, + mContext.getString(R.string.keyguard_unlock)); + } + @Test public void onBiometricError_whenFaceIsLocked_onMultipleLockOutErrors_showUnavailableMessage() { createController();