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>
This commit is contained in:
Beverly Tai
2023-01-26 22:46:32 +00:00
committed by Automerger Merge Worker
2 changed files with 39 additions and 20 deletions

View File

@@ -43,6 +43,7 @@ import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON;
import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY; import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;
import static com.android.systemui.plugins.log.LogLevel.ERROR; import static com.android.systemui.plugins.log.LogLevel.ERROR;
import android.app.AlarmManager;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@@ -98,6 +99,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.KeyguardStateController; 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.concurrency.DelayableExecutor;
import com.android.systemui.util.wakelock.SettableWakeLock; import com.android.systemui.util.wakelock.SettableWakeLock;
import com.android.systemui.util.wakelock.WakeLock; import com.android.systemui.util.wakelock.WakeLock;
@@ -127,10 +129,8 @@ public class KeyguardIndicationController {
private static final String TAG = "KeyguardIndication"; private static final String TAG = "KeyguardIndication";
private static final boolean DEBUG_CHARGING_SPEED = false; 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 = 1;
private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2; private static final int MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON = 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 long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300; private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300;
public static final long DEFAULT_HIDE_DELAY_MS = public static final long DEFAULT_HIDE_DELAY_MS =
3500 + KeyguardIndicationTextView.Y_IN_DURATION; 3500 + KeyguardIndicationTextView.Y_IN_DURATION;
@@ -212,6 +212,11 @@ public class KeyguardIndicationController {
}; };
private boolean mFaceLockedOutThisAuthSession; 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. * Creates a new KeyguardIndicationController and registers callbacks.
*/ */
@@ -238,7 +243,9 @@ public class KeyguardIndicationController {
AccessibilityManager accessibilityManager, AccessibilityManager accessibilityManager,
FaceHelpMessageDeferral faceHelpMessageDeferral, FaceHelpMessageDeferral faceHelpMessageDeferral,
KeyguardLogger keyguardLogger, KeyguardLogger keyguardLogger,
AlternateBouncerInteractor alternateBouncerInteractor) { AlternateBouncerInteractor alternateBouncerInteractor,
AlarmManager alarmManager
) {
mContext = context; mContext = context;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
mDevicePolicyManager = devicePolicyManager; mDevicePolicyManager = devicePolicyManager;
@@ -273,17 +280,26 @@ public class KeyguardIndicationController {
mHandler = new Handler(mainLooper) { mHandler = new Handler(mainLooper) {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (msg.what == MSG_HIDE_TRANSIENT) { if (msg.what == MSG_SHOW_ACTION_TO_UNLOCK) {
hideTransientIndication();
} else if (msg.what == MSG_SHOW_ACTION_TO_UNLOCK) {
showActionToUnlock(); showActionToUnlock();
} else if (msg.what == MSG_HIDE_BIOMETRIC_MESSAGE) {
hideBiometricMessage();
} else if (msg.what == MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON) { } else if (msg.what == MSG_RESET_ERROR_MESSAGE_ON_SCREEN_ON) {
mBiometricErrorMessageToShowOnScreenOn = null; 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. */ /** Call this after construction to finish setting up the instance. */
@@ -335,6 +351,8 @@ public class KeyguardIndicationController {
*/ */
public void destroy() { public void destroy() {
mHandler.removeCallbacksAndMessages(null); mHandler.removeCallbacksAndMessages(null);
mHideBiometricMessageHandler.cancel();
mHideTransientMessageHandler.cancel();
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver); mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
} }
@@ -679,7 +697,7 @@ public class KeyguardIndicationController {
if (visible) { if (visible) {
// If this is called after an error message was already shown, we should not clear it. // If this is called after an error message was already shown, we should not clear it.
// Otherwise the error message won't be shown // Otherwise the error message won't be shown
if (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) { if (!mHideTransientMessageHandler.isScheduled()) {
hideTransientIndication(); hideTransientIndication();
} }
updateDeviceEntryIndication(false); updateDeviceEntryIndication(false);
@@ -727,16 +745,14 @@ public class KeyguardIndicationController {
* Hides transient indication in {@param delayMs}. * Hides transient indication in {@param delayMs}.
*/ */
public void hideTransientIndicationDelayed(long delayMs) { public void hideTransientIndicationDelayed(long delayMs) {
mHandler.sendMessageDelayed( mHideTransientMessageHandler.schedule(delayMs, AlarmTimeout.MODE_RESCHEDULE_IF_SCHEDULED);
mHandler.obtainMessage(MSG_HIDE_TRANSIENT), delayMs);
} }
/** /**
* Hides biometric indication in {@param delayMs}. * Hides biometric indication in {@param delayMs}.
*/ */
public void hideBiometricMessageDelayed(long delayMs) { public void hideBiometricMessageDelayed(long delayMs) {
mHandler.sendMessageDelayed( mHideBiometricMessageHandler.schedule(delayMs, AlarmTimeout.MODE_RESCHEDULE_IF_SCHEDULED);
mHandler.obtainMessage(MSG_HIDE_BIOMETRIC_MESSAGE), delayMs);
} }
/** /**
@@ -751,7 +767,6 @@ public class KeyguardIndicationController {
*/ */
private void showTransientIndication(CharSequence transientIndication) { private void showTransientIndication(CharSequence transientIndication) {
mTransientIndication = transientIndication; mTransientIndication = transientIndication;
mHandler.removeMessages(MSG_HIDE_TRANSIENT);
hideTransientIndicationDelayed(DEFAULT_HIDE_DELAY_MS); hideTransientIndicationDelayed(DEFAULT_HIDE_DELAY_MS);
updateTransient(); updateTransient();
@@ -777,7 +792,6 @@ public class KeyguardIndicationController {
mBiometricMessageFollowUp = biometricMessageFollowUp; mBiometricMessageFollowUp = biometricMessageFollowUp;
mHandler.removeMessages(MSG_SHOW_ACTION_TO_UNLOCK); mHandler.removeMessages(MSG_SHOW_ACTION_TO_UNLOCK);
mHandler.removeMessages(MSG_HIDE_BIOMETRIC_MESSAGE);
hideBiometricMessageDelayed( hideBiometricMessageDelayed(
mBiometricMessageFollowUp != null mBiometricMessageFollowUp != null
? IMPORTANT_MSG_MIN_DURATION * 2 ? IMPORTANT_MSG_MIN_DURATION * 2
@@ -791,7 +805,7 @@ public class KeyguardIndicationController {
if (mBiometricMessage != null || mBiometricMessageFollowUp != null) { if (mBiometricMessage != null || mBiometricMessageFollowUp != null) {
mBiometricMessage = null; mBiometricMessage = null;
mBiometricMessageFollowUp = null; mBiometricMessageFollowUp = null;
mHandler.removeMessages(MSG_HIDE_BIOMETRIC_MESSAGE); mHideBiometricMessageHandler.cancel();
updateBiometricMessage(); updateBiometricMessage();
} }
} }
@@ -802,7 +816,7 @@ public class KeyguardIndicationController {
public void hideTransientIndication() { public void hideTransientIndication() {
if (mTransientIndication != null) { if (mTransientIndication != null) {
mTransientIndication = null; mTransientIndication = null;
mHandler.removeMessages(MSG_HIDE_TRANSIENT); mHideTransientMessageHandler.cancel();
updateTransient(); updateTransient();
} }
} }

View File

@@ -58,6 +58,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.app.AlarmManager;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyResourcesManager; import android.app.admin.DevicePolicyResourcesManager;
@@ -183,6 +184,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
private ScreenLifecycle mScreenLifecycle; private ScreenLifecycle mScreenLifecycle;
@Mock @Mock
private AuthController mAuthController; private AuthController mAuthController;
@Mock
private AlarmManager mAlarmManager;
@Captor @Captor
private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener; private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
@Captor @Captor
@@ -277,7 +280,9 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
mAuthController, mLockPatternUtils, mScreenLifecycle, mAuthController, mLockPatternUtils, mScreenLifecycle,
mKeyguardBypassController, mAccessibilityManager, mKeyguardBypassController, mAccessibilityManager,
mFaceHelpMessageDeferral, mock(KeyguardLogger.class), mFaceHelpMessageDeferral, mock(KeyguardLogger.class),
mAlternateBouncerInteractor); mAlternateBouncerInteractor,
mAlarmManager
);
mController.init(); mController.init();
mController.setIndicationArea(mIndicationArea); mController.setIndicationArea(mIndicationArea);
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture()); verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());