Fix issue with wrong token used for input consumer unregistration
- Calling TIS.onUserUnlocked() will create a new InputConsumerController
and also call register() on that consumer, which will under the hood
destroy and create the consumer with WM. However, if onUserUnlocked()
is called multiple times (generally not the case), the second call
will trigger the creation of a new InputConsumerController and try
to call destroy with the new consumer's token instead of the old
one, and when it creates a new consumer WM will throw an exception
complaining that there is already a consumer.
We should instead use the same input consumer controller instance
for each registration so that we can destroy with the same token that
was previously used to create the consumer
Fixes: 313284686
Test: Force trigger onUserUnlocked() multiple times and ensure no crash
Change-Id: I67da9a1ca82568770d470fd94f17378fd50c02f4
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 5228420..b6b7d58 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -491,6 +491,7 @@
mDeviceState = new RecentsAnimationDeviceState(this, true);
mTaskbarManager = new TaskbarManager(this);
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
+ mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
BootAwarePreloader.start(this);
// Call runOnUserUnlocked() before any other callbacks to ensure everything is initialized.
@@ -538,13 +539,13 @@
@UiThread
public void onUserUnlocked() {
+ Log.d(TAG, "onUserUnlocked: userId=" + getUserId());
mTaskAnimationManager = new TaskAnimationManager(this);
mOverviewComponentObserver = new OverviewComponentObserver(this, mDeviceState);
mOverviewCommandHelper = new OverviewCommandHelper(this,
mOverviewComponentObserver, mTaskAnimationManager);
mResetGestureInputConsumer = new ResetGestureInputConsumer(
mTaskAnimationManager, mTaskbarManager::getCurrentActivityContext);
- mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
mInputConsumer.registerInputConsumer();
onSystemUiFlagsChanged(mDeviceState.getSystemUiStateFlags());
onAssistantVisibilityChanged();