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

Commit 85b5dee2 authored by Beverly's avatar Beverly
Browse files

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
parent 72922c8a
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -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();
            }
        }
    };
}
+8 −0
Original line number Diff line number Diff line
@@ -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.
     */
+9 −2
Original line number Diff line number Diff line
@@ -154,6 +154,9 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
    private ArgumentCaptor<BroadcastReceiver> mBroadcastReceiverCaptor;
    @Captor
    private ArgumentCaptor<KeyguardIndication> mKeyguardIndicationCaptor;
    @Captor
    private ArgumentCaptor<KeyguardStateController.Callback> 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());
    }