Merge "Ensure AoD transient messagesa are updated" into tm-qpr-dev am: 4c71a7841c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21062821
Change-Id: I45000597659742bc38268d9d1524056615bb1237
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 006b552..6481855 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -43,6 +43,7 @@
import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;
import static com.android.systemui.plugins.log.LogLevel.ERROR;
+import android.app.AlarmManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -98,6 +99,7 @@
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
+import com.android.systemui.util.AlarmTimeout;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.wakelock.SettableWakeLock;
import com.android.systemui.util.wakelock.WakeLock;
@@ -127,10 +129,8 @@
private static final String TAG = "KeyguardIndication";
private static final boolean DEBUG_CHARGING_SPEED = false;
- private static final int MSG_HIDE_TRANSIENT = 1;
- private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2;
- private static final int MSG_HIDE_BIOMETRIC_MESSAGE = 3;
- private static final int MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON = 4;
+ private static final int MSG_SHOW_ACTION_TO_UNLOCK = 1;
+ private static final int MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON = 2;
private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300;
public static final long DEFAULT_HIDE_DELAY_MS =
3500 + KeyguardIndicationTextView.Y_IN_DURATION;
@@ -212,6 +212,11 @@
};
private boolean mFaceLockedOutThisAuthSession;
+ // Use AlarmTimeouts to guarantee that the events are handled even if scheduled and
+ // triggered while the device is asleep
+ private final AlarmTimeout mHideTransientMessageHandler;
+ private final AlarmTimeout mHideBiometricMessageHandler;
+
/**
* Creates a new KeyguardIndicationController and registers callbacks.
*/
@@ -238,7 +243,9 @@
AccessibilityManager accessibilityManager,
FaceHelpMessageDeferral faceHelpMessageDeferral,
KeyguardLogger keyguardLogger,
- AlternateBouncerInteractor alternateBouncerInteractor) {
+ AlternateBouncerInteractor alternateBouncerInteractor,
+ AlarmManager alarmManager
+ ) {
mContext = context;
mBroadcastDispatcher = broadcastDispatcher;
mDevicePolicyManager = devicePolicyManager;
@@ -273,17 +280,26 @@
mHandler = new Handler(mainLooper) {
@Override
public void handleMessage(Message msg) {
- if (msg.what == MSG_HIDE_TRANSIENT) {
- hideTransientIndication();
- } else if (msg.what == MSG_SHOW_ACTION_TO_UNLOCK) {
+ if (msg.what == MSG_SHOW_ACTION_TO_UNLOCK) {
showActionToUnlock();
- } else if (msg.what == MSG_HIDE_BIOMETRIC_MESSAGE) {
- hideBiometricMessage();
} else if (msg.what == MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON) {
mBiometricErrorMessageToShowOnScreenOn = null;
}
}
};
+
+ mHideTransientMessageHandler = new AlarmTimeout(
+ alarmManager,
+ this::hideTransientIndication,
+ TAG,
+ mHandler
+ );
+ mHideBiometricMessageHandler = new AlarmTimeout(
+ alarmManager,
+ this::hideBiometricMessage,
+ TAG,
+ mHandler
+ );
}
/** Call this after construction to finish setting up the instance. */
@@ -335,6 +351,8 @@
*/
public void destroy() {
mHandler.removeCallbacksAndMessages(null);
+ mHideBiometricMessageHandler.cancel();
+ mHideTransientMessageHandler.cancel();
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
}
@@ -679,7 +697,7 @@
if (visible) {
// If this is called after an error message was already shown, we should not clear it.
// Otherwise the error message won't be shown
- if (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) {
+ if (!mHideTransientMessageHandler.isScheduled()) {
hideTransientIndication();
}
updateDeviceEntryIndication(false);
@@ -727,16 +745,14 @@
* Hides transient indication in {@param delayMs}.
*/
public void hideTransientIndicationDelayed(long delayMs) {
- mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MSG_HIDE_TRANSIENT), delayMs);
+ mHideTransientMessageHandler.schedule(delayMs, AlarmTimeout.MODE_RESCHEDULE_IF_SCHEDULED);
}
/**
* Hides biometric indication in {@param delayMs}.
*/
public void hideBiometricMessageDelayed(long delayMs) {
- mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MSG_HIDE_BIOMETRIC_MESSAGE), delayMs);
+ mHideBiometricMessageHandler.schedule(delayMs, AlarmTimeout.MODE_RESCHEDULE_IF_SCHEDULED);
}
/**
@@ -751,7 +767,6 @@
*/
private void showTransientIndication(CharSequence transientIndication) {
mTransientIndication = transientIndication;
- mHandler.removeMessages(MSG_HIDE_TRANSIENT);
hideTransientIndicationDelayed(DEFAULT_HIDE_DELAY_MS);
updateTransient();
@@ -777,7 +792,6 @@
mBiometricMessageFollowUp = biometricMessageFollowUp;
mHandler.removeMessages(MSG_SHOW_ACTION_TO_UNLOCK);
- mHandler.removeMessages(MSG_HIDE_BIOMETRIC_MESSAGE);
hideBiometricMessageDelayed(
mBiometricMessageFollowUp != null
? IMPORTANT_MSG_MIN_DURATION * 2
@@ -791,7 +805,7 @@
if (mBiometricMessage != null || mBiometricMessageFollowUp != null) {
mBiometricMessage = null;
mBiometricMessageFollowUp = null;
- mHandler.removeMessages(MSG_HIDE_BIOMETRIC_MESSAGE);
+ mHideBiometricMessageHandler.cancel();
updateBiometricMessage();
}
}
@@ -802,7 +816,7 @@
public void hideTransientIndication() {
if (mTransientIndication != null) {
mTransientIndication = null;
- mHandler.removeMessages(MSG_HIDE_TRANSIENT);
+ mHideTransientMessageHandler.cancel();
updateTransient();
}
}
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 610bb13..dffa566 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
@@ -58,6 +58,7 @@
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import android.app.AlarmManager;
import android.app.Instrumentation;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyResourcesManager;
@@ -183,6 +184,8 @@
private ScreenLifecycle mScreenLifecycle;
@Mock
private AuthController mAuthController;
+ @Mock
+ private AlarmManager mAlarmManager;
@Captor
private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
@Captor
@@ -277,7 +280,9 @@
mAuthController, mLockPatternUtils, mScreenLifecycle,
mKeyguardBypassController, mAccessibilityManager,
mFaceHelpMessageDeferral, mock(KeyguardLogger.class),
- mAlternateBouncerInteractor);
+ mAlternateBouncerInteractor,
+ mAlarmManager
+ );
mController.init();
mController.setIndicationArea(mIndicationArea);
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());