From 85b5dee2f109140d74a415e60bf27f4ae495a268 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 20 Jul 2021 15:44:24 -0400 Subject: [PATCH] Reset messages when the keyguard isn't showing - biometric error messages require a minimum amount of time to be shown but aren't relevant once the device is unlocked, so clear the keyguard indication messages once the keyguard isn't showing anymore - don't show any face errors for co-ex Test: manual, atest SystemUITests Fixes: 192981147 Change-Id: Ia11ffc740e5505aafb7f96635909bf7f5cd10341 --- .../KeyguardIndicationController.java | 40 ++++++++++--------- .../phone/KeyguardIndicationTextView.java | 8 ++++ .../KeyguardIndicationControllerTest.java | 11 ++++- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 44399a1266247..4d15a0afdd0a2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -94,7 +94,7 @@ import javax.inject.Inject; * Controls the indications and error messages shown on the Keyguard */ @SysUISingleton -public class KeyguardIndicationController implements KeyguardStateController.Callback { +public class KeyguardIndicationController { private static final String TAG = "KeyguardIndication"; private static final boolean DEBUG_CHARGING_SPEED = false; @@ -206,7 +206,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal mKeyguardUpdateMonitor.registerCallback(getKeyguardCallback()); mKeyguardUpdateMonitor.registerCallback(mTickReceiver); mStatusBarStateController.addCallback(mStatusBarStateListener); - mKeyguardStateController.addCallback(this); + mKeyguardStateController.addCallback(mKeyguardStateCallback); mStatusBarStateListener.onDozingChanged(mStatusBarStateController.isDozing()); } @@ -827,11 +827,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal mRotateTextViewController.dump(fd, pw, args); } - @Override - public void onUnlockedChanged() { - updateIndication(false); - } - protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback { public static final int HIDE_DELAY_MS = 5000; @@ -890,10 +885,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal mStatusBarKeyguardViewManager.showBouncerMessage(helpString, mInitialTextColorState); } else if (mKeyguardUpdateMonitor.isScreenOn()) { - if (biometricSourceType == BiometricSourceType.FACE - && shouldSuppressFaceMsgAndShowTryFingerprintMsg()) { - // suggest trying fingerprint - showTransientIndication(R.string.keyguard_try_fingerprint); + if (biometricSourceType == BiometricSourceType.FACE && shouldSuppressFaceMsg()) { return; } showTransientIndication(helpString, false /* isError */, showSwipeToUnlock); @@ -911,11 +903,9 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal return; } if (biometricSourceType == BiometricSourceType.FACE - && shouldSuppressFaceMsgAndShowTryFingerprintMsg() + && shouldSuppressFaceMsg() && !mStatusBarKeyguardViewManager.isBouncerShowing() && mKeyguardUpdateMonitor.isScreenOn()) { - // suggest trying fingerprint - showTransientIndication(R.string.keyguard_try_fingerprint); return; } if (msgId == FaceManager.FACE_ERROR_TIMEOUT) { @@ -966,11 +956,9 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal || msgId == FingerprintManager.FINGERPRINT_ERROR_USER_CANCELED); } - private boolean shouldSuppressFaceMsgAndShowTryFingerprintMsg() { - // For dual biometric, don't show face auth messages unless face auth was explicitly - // requested by the user. + private boolean shouldSuppressFaceMsg() { + // For dual biometric, don't show face auth messages return mKeyguardUpdateMonitor.isFingerprintDetectionRunning() - && !mKeyguardUpdateMonitor.isFaceAuthUserRequested() && mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed( true /* isStrongBiometric */); } @@ -1068,4 +1056,20 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal updateIndication(false); } }; + + private KeyguardStateController.Callback mKeyguardStateCallback = + new KeyguardStateController.Callback() { + @Override + public void onUnlockedChanged() { + updateIndication(false); + } + + @Override + public void onKeyguardShowingChanged() { + if (!mKeyguardStateController.isShowing()) { + mTopIndicationView.clearMessages(); + mLockScreenIndicationView.clearMessages(); + } + } + }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardIndicationTextView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardIndicationTextView.java index 178974327a75c..f1cde8a9be7ae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardIndicationTextView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardIndicationTextView.java @@ -61,6 +61,14 @@ public class KeyguardIndicationTextView extends TextView { super(context, attrs, defStyleAttr, defStyleRes); } + /** + * Clears message queue. + */ + public void clearMessages() { + mMessages.clear(); + mKeyguardIndicationInfo.clear(); + } + /** * Changes the text with an animation and makes sure a single indication is shown long enough. */ 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 1ba3831277cd2..298bd9a3082dd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -154,6 +154,9 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { private ArgumentCaptor mBroadcastReceiverCaptor; @Captor private ArgumentCaptor mKeyguardIndicationCaptor; + @Captor + private ArgumentCaptor mKeyguardStateControllerCallbackCaptor; + private KeyguardStateController.Callback mKeyguardStateControllerCallback; private StatusBarStateController.StateListener mStatusBarStateListener; private BroadcastReceiver mBroadcastReceiver; private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock()); @@ -223,6 +226,10 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mController.mRotateTextViewController = mRotateTextViewController; mController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); clearInvocations(mIBatteryStats); + + verify(mKeyguardStateController).addCallback( + mKeyguardStateControllerCallbackCaptor.capture()); + mKeyguardStateControllerCallback = mKeyguardStateControllerCallbackCaptor.getValue(); } @Test @@ -529,7 +536,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { reset(mKeyguardUpdateMonitor); when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true); when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false); - mController.onUnlockedChanged(); + mKeyguardStateControllerCallback.onUnlockedChanged(); verifyIndicationMessage(INDICATION_TYPE_RESTING, restingIndication); } @@ -572,7 +579,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { @Test public void updateMonitor_listener() { createController(); - verify(mKeyguardStateController).addCallback(eq(mController)); + verify(mKeyguardStateController).addCallback(any()); verify(mKeyguardUpdateMonitor, times(2)).registerCallback(any()); }