Remove user TIS unlocked runnable when a TIS instance is destroyed
- If the TIS instance is destroyed, then we should remove any queued
user-unlocked runnables to ensure that they do not attempt to run
again
Flag: EXEMPT bugfix
Bug: 373671447
Test: atest NexusLauncherTests
Change-Id: I8ca3cdfa6f849bce5d347f14038e1ebd6bc6ff06
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index f0943dc..4ee8747 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -606,6 +606,9 @@
this::createFallbackSwipeHandler;
private final AbsSwipeUpHandler.Factory mRecentsWindowSwipeHandlerFactory =
this::createRecentsWindowSwipeHandler;
+ // This needs to be a member to be queued and potentially removed later if the service is
+ // destroyed before the user is unlocked
+ private final Runnable mUserUnlockedRunnable = this::onUserUnlocked;
private final ScreenOnTracker.ScreenOnListener mScreenOnListener = this::onScreenOnChanged;
@@ -677,8 +680,7 @@
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
// Call runOnUserUnlocked() before any other callbacks to ensure everything is initialized.
- LockedUserState.get(this).runOnUserUnlocked(this::onUserUnlocked);
- LockedUserState.get(this).runOnUserUnlocked(mTaskbarManager::onUserUnlocked);
+ LockedUserState.get(this).runOnUserUnlocked(mUserUnlockedRunnable);
mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
sConnected = true;
@@ -745,6 +747,8 @@
mOverviewComponentObserver.setOverviewChangeListener(this::onOverviewTargetChange);
onOverviewTargetChange(mOverviewComponentObserver.isHomeAndOverviewSame());
+
+ mTaskbarManager.onUserUnlocked();
}
public OverviewCommandHelper getOverviewCommandHelper() {
@@ -835,6 +839,7 @@
mDesktopVisibilityController.onDestroy();
sConnected = false;
+ LockedUserState.get(this).removeOnUserUnlockedRunnable(mUserUnlockedRunnable);
ScreenOnTracker.INSTANCE.get(this).removeListener(mScreenOnListener);
super.onDestroy();
}
diff --git a/src/com/android/launcher3/util/LockedUserState.kt b/src/com/android/launcher3/util/LockedUserState.kt
index 10559f3..c8d86d4 100644
--- a/src/com/android/launcher3/util/LockedUserState.kt
+++ b/src/com/android/launcher3/util/LockedUserState.kt
@@ -88,6 +88,13 @@
mUserUnlockedActions.add(action)
}
+ /**
+ * Removes a previously queued `Runnable` to be run when the user is unlocked.
+ */
+ fun removeOnUserUnlockedRunnable(action: Runnable) {
+ mUserUnlockedActions.remove(action)
+ }
+
companion object {
@VisibleForTesting
@JvmField