diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 615e3e326e..3ed2d0bdb8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -19,7 +19,7 @@ import static com.android.app.animation.Interpolators.DECELERATE_3; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL_APPS_EDU; import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS; -import static com.android.launcher3.LauncherAnimUtils.newCancelListener; +import static com.android.launcher3.LauncherAnimUtils.newSingleUseCancelListener; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; @@ -47,7 +47,6 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.touch.SingleAxisSwipeDetector; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.TouchController; import com.android.quickstep.TaskUtils; @@ -166,7 +165,7 @@ public class NavBarToHomeTouchController implements TouchController, topView.addHintCloseAnim(mPullbackDistance, PULLBACK_INTERPOLATOR, builder); } mCurrentAnimation = builder.createPlaybackController(); - mCurrentAnimation.getTarget().addListener(newCancelListener(this::clearState)); + mCurrentAnimation.getTarget().addListener(newSingleUseCancelListener(this::clearState)); } private void clearState() { diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 26e994f4e4..42be52f7c4 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -18,7 +18,7 @@ package com.android.launcher3.uioverrides.touchcontrollers; import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE; import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR; -import static com.android.launcher3.LauncherAnimUtils.newCancelListener; +import static com.android.launcher3.LauncherAnimUtils.newSingleUseCancelListener; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.HINT_STATE; import static com.android.launcher3.LauncherState.NORMAL; @@ -226,7 +226,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch return; } mNormalToHintOverviewScrimAnimator = null; - mCurrentAnimation.getTarget().addListener(newCancelListener(() -> + mCurrentAnimation.getTarget().addListener(newSingleUseCancelListener(() -> mLauncher.getStateManager().goToState(OVERVIEW, true, forSuccessCallback(() -> { mOverviewResistYAnim = AnimatorControllerWithResistance .createRecentsResistanceFromOverviewAnim(mLauncher, null) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 5a19ed42db..527a776d10 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -109,7 +109,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, private final float mMotionPauseMinDisplacement; private final RecentsView mRecentsView; protected final AnimatorListener mClearStateOnCancelListener = - newCancelListener(this::clearState); + newCancelListener(this::clearState, /* isSingleUse = */ false); private boolean mNoIntercept; private LauncherState mStartState; diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 879fccbc9f..711882c7b6 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -97,6 +97,13 @@ public class RecentTasksList { RecentTasksList.this.onRunningTaskVanished(taskInfo); }); } + + @Override + public void onRunningTaskChanged(ActivityManager.RunningTaskInfo taskInfo) { + mMainThreadExecutor.execute(() -> { + RecentTasksList.this.onRunningTaskChanged(taskInfo); + }); + } }); // We may receive onRunningTaskAppeared events later for tasks which have already been // included in the list returned by mSysUiProxy.getRunningTasks(), or may receive @@ -244,6 +251,20 @@ public class RecentTasksList { } } + private void onRunningTaskChanged(ActivityManager.RunningTaskInfo taskInfo) { + // Find the task from the list of running tasks, if it exists + for (ActivityManager.RunningTaskInfo existingTask : mRunningTasks) { + if (existingTask.taskId != taskInfo.taskId) continue; + + mRunningTasks.remove(existingTask); + mRunningTasks.add(taskInfo); + if (mRunningTasksListener != null) { + mRunningTasksListener.onRunningTasksChanged(); + } + return; + } + } + /** * Loads and creates a list of all the recent tasks. */ @@ -390,4 +411,4 @@ public class RecentTasksList { return mRequestId == requestId && (!mKeysOnly || loadKeysOnly); } } -} \ No newline at end of file +} diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java index d04e389975..4b20d600dc 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java @@ -17,8 +17,6 @@ package com.android.quickstep; import static com.android.launcher3.Flags.enableCursorHoverStates; import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME; -import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL; -import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT; import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT; import static org.junit.Assume.assumeTrue; @@ -26,9 +24,6 @@ import static org.junit.Assume.assumeTrue; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; -import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape; -import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; -import com.android.launcher3.util.rule.TestStabilityRule; import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch; import org.junit.Test; @@ -72,9 +67,6 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar { @Test @TaskbarModeSwitch(mode = TRANSIENT) - @PortraitLandscape - @ScreenRecord // b/317798731 - @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/321083190 public void testSwipeToStashAndUnstash() { getTaskbar().swipeDownToStash(); mLauncher.getLaunchedAppState().swipeUpToUnstashTaskbar(); diff --git a/res/drawable/ic_private_space_with_background.xml b/res/drawable/ic_private_space_with_background.xml index da199f0cfd..cb37c9add5 100644 --- a/res/drawable/ic_private_space_with_background.xml +++ b/res/drawable/ic_private_space_with_background.xml @@ -22,9 +22,11 @@ android:pathData="M48 24A24 24 0 0 1 0 24A24 24 0 0 1 48 24Z" android:fillColor="?androidprv:attr/materialColorSurfaceContainerLowest" /> diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index c20f323055..6a9d170b2c 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -220,17 +220,28 @@ public class LauncherAnimUtils { /** * Utility method to create an {@link AnimatorListener} which executes a callback on animation - * cancel. + * cancel. Once the cancel has been dispatched, this listener will no longer be called. */ - public static AnimatorListener newCancelListener(Runnable callback) { - return new AnimatorListenerAdapter() { + public static AnimatorListener newSingleUseCancelListener(Runnable callback) { + return newCancelListener(callback, true); + } + /** + * Utility method to create an {@link AnimatorListener} which executes a callback on animation + * cancel. + * + * @param isSingleUse {@code true} means the callback will be called at most once + */ + public static AnimatorListener newCancelListener(Runnable callback, boolean isSingleUse) { + return new AnimatorListenerAdapter() { boolean mDispatched = false; @Override public void onAnimationCancel(Animator animation) { if (!mDispatched) { - mDispatched = true; + if (isSingleUse) { + mDispatched = true; + } callback.run(); } } diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index af704a88f0..329f71777e 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -572,7 +572,7 @@ public class IconCache extends BaseIconCache { try (LauncherIcons li = LauncherIcons.obtain(mContext)) { final BitmapInfo tempBitmap = li.createBadgedIconBitmap( mContext.getDrawable(widgetSection.mSectionDrawable), - new BaseIconFactory.IconOptions().setShrinkNonAdaptiveIcons(false)); + new BaseIconFactory.IconOptions()); mWidgetCategoryBitmapInfos.put(infoInOut.widgetCategory, tempBitmap); infoInOut.bitmap = getBadgedIcon(tempBitmap, infoInOut.user); } catch (Exception e) { diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index d5c9b9fa89..ab8b94e81d 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -41,6 +41,7 @@ import androidx.annotation.Keep; import androidx.annotation.Nullable; import androidx.core.view.WindowInsetsCompat; +import com.android.launcher3.BaseActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; @@ -136,6 +137,10 @@ public class TestInformationHandler implements ResourceBasedOverride { }); } + case TestProtocol.REQUEST_IS_LAUNCHER_BINDING: { + return getUIProperty(Bundle::putBoolean, t -> isLauncherBinding(), () -> true); + } + case TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED: { return getUIProperty(Bundle::putBoolean, t -> isLauncherInitialized(), () -> true); } @@ -484,6 +489,11 @@ public class TestInformationHandler implements ResourceBasedOverride { return target; } + protected boolean isLauncherBinding() { + BaseActivity baseActivity = Launcher.ACTIVITY_TRACKER.getCreatedActivity(); + return baseActivity != null && baseActivity.isBindingItems(); + } + protected boolean isLauncherInitialized() { return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null || LauncherAppState.getInstance(mContext).getModel().isModelLoaded(); diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 9aed4ebb51..50f98f297b 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -57,7 +57,7 @@ public abstract class AbstractStateChangeTouchController protected final SingleAxisSwipeDetector.Direction mSwipeDirection; protected final AnimatorListener mClearStateOnCancelListener = - newCancelListener(this::clearState); + newCancelListener(this::clearState, /* isSingleUse = */ false); private final FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck(); protected int mStartContainerType; diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java index fea0330a16..d029dd8457 100644 --- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -87,6 +87,7 @@ public final class TestProtocol { "home-to-all-apps-swipe-height"; public static final String REQUEST_ICON_HEIGHT = "icon-height"; + public static final String REQUEST_IS_LAUNCHER_BINDING = "is-launcher-binding"; public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized"; public static final String REQUEST_IS_LAUNCHER_LAUNCHER_ACTIVITY_STARTED = "is-launcher-activity-started"; diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java index df71ec09d4..b7933c8aff 100644 --- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java +++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java @@ -39,6 +39,7 @@ import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape; import com.android.launcher3.util.TestUtil; import com.android.launcher3.util.Wait; +import com.android.launcher3.util.rule.ScreenRecordRule; import com.android.launcher3.util.rule.TestStabilityRule; import org.junit.Test; @@ -132,6 +133,7 @@ public class TaplUninstallRemoveTest extends AbstractLauncherUiTest { */ @Test @PlatinumTest(focusArea = "launcher") + @ScreenRecordRule.ScreenRecord // b/319501259 public void uninstallWorkspaceIcon() throws IOException { Point[] gridPositions = TestUtil.getCornersAndCenterPositions(mLauncher); StringBuilder sb = new StringBuilder(); @@ -162,12 +164,10 @@ public class TaplUninstallRemoveTest extends AbstractLauncherUiTest { mLauncher.getWorkspace().verifyWorkspaceAppIconIsGone( DUMMY_APP_NAME + " was expected to disappear after uninstall.", DUMMY_APP_NAME); - if (!TestStabilityRule.isPresubmit()) { // b/315847371 - Log.d(UIOBJECT_STALE_ELEMENT, "second getWorkspaceIconsPositions()"); - Map finalPositions = - mLauncher.getWorkspace().getWorkspaceIconsPositions(); - assertThat(finalPositions).doesNotContainKey(DUMMY_APP_NAME); - } + Log.d(UIOBJECT_STALE_ELEMENT, "second getWorkspaceIconsPositions()"); + Map finalPositions = + mLauncher.getWorkspace().getWorkspaceIconsPositions(); + assertThat(finalPositions).doesNotContainKey(DUMMY_APP_NAME); } finally { TestUtil.uninstallDummyApp(); } diff --git a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java index 79724e1189..19c585085b 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.ui.widget; -import static com.android.launcher3.util.rule.ShellCommandRule.createEnableInputTransportPublisherRule; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -32,9 +30,7 @@ import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.launcher3.widget.picker.WidgetsRecyclerView; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestRule; import org.junit.runner.RunWith; /** @@ -44,9 +40,6 @@ import org.junit.runner.RunWith; @MediumTest @RunWith(AndroidJUnit4.class) public class TaplWidgetPickerTest extends AbstractLauncherUiTest { - // b/325377690 : To get the log printed where DOWN key event is getting lost from TAPL. - @Rule public final TestRule mEnableInputTransportPublisherRule = - createEnableInputTransportPublisherRule(); private WidgetsRecyclerView getWidgetsView(Launcher launcher) { return WidgetsFullSheet.getWidgetsView(launcher); diff --git a/tests/src/com/android/launcher3/util/rule/SetPropRule.java b/tests/src/com/android/launcher3/util/rule/SetPropRule.java new file mode 100644 index 0000000000..74fec35fa2 --- /dev/null +++ b/tests/src/com/android/launcher3/util/rule/SetPropRule.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.util.rule; + +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; + +import android.text.TextUtils; + +import androidx.annotation.NonNull; +import androidx.test.uiautomator.UiDevice; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * Test rule which executes a set prop command at the start of the test. + * This rule needs the property tag and property value so that value can be set to a tag. + */ +public class SetPropRule implements TestRule { + private static final String SETPROP_PREFIX = "setprop"; + private static final String GETPROP_PREFIX = "getprop"; + private static final String UNKNOWN = "UNKNOWN"; + @NonNull private final String mPropTag; + @NonNull private final String mPropValue; + + public SetPropRule(@NonNull String propTag, @NonNull String propValue) { + mPropTag = propTag.trim(); + mPropValue = propValue.trim(); + } + + @Override + public Statement apply(Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + String getpropCmd = GETPROP_PREFIX + " " + mPropTag; + String initialValue = UiDevice.getInstance(getInstrumentation()) + .executeShellCommand(getpropCmd); + if (TextUtils.isEmpty(initialValue.trim())) { + initialValue = UNKNOWN; + } + // setprop command always follows format : setprop + String revertSetPropCmd = SETPROP_PREFIX + " " + mPropTag + " " + initialValue; + String setPropCmd = SETPROP_PREFIX + " " + mPropTag + " " + mPropValue; + new ShellCommandRule(setPropCmd, revertSetPropCmd) + .apply(base, description).evaluate(); + } + }; + } + + /** + * Enables "InputTransportPublisher" debug flag. This prints the key input events dispatched by + * the system server. + * adb shell setprop log.tag.InputTransportPublisher DEBUG + * See {@link com.android.cts.input.DebugInputRule} for more details. + */ + public static SetPropRule createEnableInputTransportPublisherRule() { + return new SetPropRule("log.tag.InputTransportPublisher", "DEBUG"); + } +} diff --git a/tests/src/com/android/launcher3/util/rule/ShellCommandRule.java b/tests/src/com/android/launcher3/util/rule/ShellCommandRule.java index 977995e4b1..2219003254 100644 --- a/tests/src/com/android/launcher3/util/rule/ShellCommandRule.java +++ b/tests/src/com/android/launcher3/util/rule/ShellCommandRule.java @@ -15,13 +15,12 @@ */ package com.android.launcher3.util.rule; -import static androidx.test.InstrumentationRegistry.getInstrumentation; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess; import android.content.ComponentName; import android.content.pm.ActivityInfo; -import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.test.InstrumentationRegistry; @@ -40,10 +39,6 @@ import java.util.ArrayList; * Test rule which executes a shell command at the start of the test. */ public class ShellCommandRule implements TestRule { - - private static final String SETPROP_PREFIX = "setprop"; - private static final String GETPROP_PREFIX = "getprop"; - private static final String UNKNOWN = "UNKNOWN"; private final String mCmd; private final String mRevertCommand; private final boolean mCheckSuccess; @@ -66,19 +61,6 @@ public class ShellCommandRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { - String revertSetPropCmd = null; - if (mCmd.startsWith(SETPROP_PREFIX) && mRevertCommand == null) { - // setprop command always follows format : setprop - // We are stripping out only the TAG here - String tag = mCmd.split("\\s")[1]; - String getpropCmd = GETPROP_PREFIX + " " + tag; - String initialValue = UiDevice.getInstance( - getInstrumentation()).executeShellCommand(getpropCmd); - if (TextUtils.isEmpty(initialValue.trim())) { - initialValue = UNKNOWN; - } - revertSetPropCmd = SETPROP_PREFIX + " " + tag + " " + initialValue; - } final String result = UiDevice.getInstance(getInstrumentation()).executeShellCommand(mCmd); if (mCheckSuccess) { @@ -90,15 +72,12 @@ public class ShellCommandRule implements TestRule { try { base.evaluate(); } finally { - if (mRevertCommand != null || revertSetPropCmd != null) { - String revertCmd = - mRevertCommand != null ? mRevertCommand : revertSetPropCmd; + if (mRevertCommand != null) { final String revertResult = UiDevice.getInstance( - getInstrumentation()).executeShellCommand( - revertCmd); + getInstrumentation()).executeShellCommand(mRevertCommand); if (mCheckSuccess) { Assert.assertTrue( - "Failed command: " + revertCmd + "Failed command: " + mRevertCommand + ", result: " + revertResult, "Success".equals(result.replaceAll("\\s", ""))); } @@ -141,14 +120,4 @@ public class ShellCommandRule implements TestRule { return new ShellCommandRule("settings put global heads_up_notifications_enabled 0", "settings put global heads_up_notifications_enabled 1"); } - - /** - * Enables "InputTransportPublisher" debug flag. This prints the key input events dispatched by - * the system server. - * adb shell setprop log.tag.InputTransportPublisher DEBUG - * See {@link com.android.cts.input.DebugInputRule} for more details. - */ - public static ShellCommandRule createEnableInputTransportPublisherRule() { - return new ShellCommandRule("setprop log.tag.InputTransportPublisher DEBUG", null); - } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 0a52955cbe..608ee34acf 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1002,6 +1002,19 @@ public final class LauncherInstrumentation { } public void waitForLauncherInitialized() { + boolean isLauncherBinding = true; + for (int i = 0; i < 100; ++i) { + isLauncherBinding = getTestInfo(TestProtocol.REQUEST_IS_LAUNCHER_BINDING) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); + if (!isLauncherBinding) { + break; + } + SystemClock.sleep(100); + } + if (isLauncherBinding) { + fail("Launcher didn't finish binding"); + } + for (int i = 0; i < 100; ++i) { if (getTestInfo( TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED). @@ -1010,7 +1023,6 @@ public final class LauncherInstrumentation { } SystemClock.sleep(100); } - checkForAnomaly(); fail("Launcher didn't initialize"); } diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index d176136e19..4fa93ef2ca 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -347,6 +347,7 @@ public final class Workspace extends Home { */ public Map getWorkspaceIconsPositions() { final UiObject2 workspace = verifyActiveContainer(); + mLauncher.waitForLauncherInitialized(); // b/319501259 List workspaceIcons = mLauncher.waitForObjectsInContainer(workspace, AppIcon.getAnyAppIconSelector()); return workspaceIcons.stream()