From 458de205381fb23ca13635e07376f3c098f1f21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Franco?= Date: Wed, 7 Feb 2024 13:23:41 -0800 Subject: [PATCH 1/2] Remove unnecesary AbstractLauncherUiTest.initialize whit two arguments Bug: 324261526 Test: atest TaplDragTest Flag: NA Change-Id: I0802d725eea222d19c8d8e60878c2f88be854ddc --- .../com/android/quickstep/TaplOverviewIconTest.java | 1 - .../android/launcher3/ui/AbstractLauncherUiTest.java | 12 +++++------- .../allapps/TaplAllAppsIconsWorkingTest.java | 2 -- .../launcher3/allapps/TaplKeyboardFocusTest.java | 1 - .../launcher3/allapps/TaplOpenCloseAllAppsTest.java | 1 - .../launcher3/appiconmenu/TaplAppIconMenuTest.java | 1 - .../com/android/launcher3/dragging/TaplDragTest.java | 2 +- .../launcher3/dragging/TaplUninstallRemoveTest.java | 1 - 8 files changed, 6 insertions(+), 15 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java index 3f806d1764..092a623e9f 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java +++ b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java @@ -15,7 +15,6 @@ */ package com.android.quickstep; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL; import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT; diff --git a/tests/multivalentTests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/multivalentTests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index f0d2e20829..978e1f2f6c 100644 --- a/tests/multivalentTests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/multivalentTests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -83,6 +83,7 @@ import org.junit.rules.RuleChain; import org.junit.rules.TestRule; import java.io.IOException; +import java.util.Objects; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -223,14 +224,9 @@ public abstract class AbstractLauncherUiTest { public SetFlagsRule mSetFlagsRule = new SetFlagsRule(DEVICE_DEFAULT); public static void initialize(AbstractLauncherUiTest test) throws Exception { - initialize(test, false); - } - - public static void initialize( - AbstractLauncherUiTest test, boolean clearWorkspace) throws Exception { - test.reinitializeLauncherData(clearWorkspace); + test.reinitializeLauncherData(); test.mDevice.pressHome(); - test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null); + test.waitForLauncherCondition("Launcher didn't start", Objects::nonNull); test.waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); test.waitForResumed("Launcher internal state is still Background"); @@ -310,6 +306,8 @@ public abstract class AbstractLauncherUiTest { } onTestStart(); + + initialize(this); } /** Method that should be called when a test starts. */ diff --git a/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java b/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java index 27a2c75795..cd05a880a0 100644 --- a/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.allapps; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; diff --git a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java index ee32e97744..db574a1dcd 100644 --- a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL; import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT; diff --git a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java index da0beb19e5..a00498cb0b 100644 --- a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java @@ -16,7 +16,6 @@ package com.android.launcher3.allapps; import static com.android.launcher3.util.TestUtil.expectFail; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java index a1f2cefb4c..ec243978de 100644 --- a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java +++ b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java @@ -16,7 +16,6 @@ package com.android.launcher3.appiconmenu; import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/tests/src/com/android/launcher3/dragging/TaplDragTest.java b/tests/src/com/android/launcher3/dragging/TaplDragTest.java index b633452bce..9942602122 100644 --- a/tests/src/com/android/launcher3/dragging/TaplDragTest.java +++ b/tests/src/com/android/launcher3/dragging/TaplDragTest.java @@ -230,7 +230,7 @@ public class TaplDragTest extends AbstractLauncherUiTest { allApps.unfreeze(); } // Reset the workspace for the next shortcut creation. - initialize(this, true); + reinitializeLauncherData(true); endTime = SystemClock.uptimeMillis(); elapsedTime = endTime - startTime; Log.d("testDragAppIconToWorkspaceCellTime", diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java index 0b9de0f029..1e765c0843 100644 --- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java +++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java @@ -16,7 +16,6 @@ package com.android.launcher3.dragging; import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING; -import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME; import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME; import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME; From b917c9ef5292866075f14369e695e0c2867130ff Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 8 Feb 2024 00:14:09 +0000 Subject: [PATCH 2/2] 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 --- .../src/com/android/quickstep/TouchInteractionService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 522842095f..b6b7d58e30 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -491,6 +491,7 @@ public class TouchInteractionService extends Service { 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 @@ public class TouchInteractionService extends Service { @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();