From e1100b904d8a258554779a0a5fde04319958f0ee Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Thu, 13 Oct 2022 13:18:36 +0100 Subject: [PATCH] Unstash taskbar when transitioning to fallback overview. Update LauncherInstrumentation taskbar visibility check to include assertions in fallback launcher using OverviewObject instead of LauncherObject. Fix: 253042501 Test: manual Change-Id: I9f2aa228e8aa97ef8ca1a4535b7f8fcded8a4572 --- .../taskbar/FallbackTaskbarUIController.java | 9 +- .../android/launcher3/tapl/Background.java | 2 +- .../launcher3/tapl/LaunchedAppState.java | 10 +- .../tapl/LauncherInstrumentation.java | 124 +++++++++++------- .../com/android/launcher3/tapl/Taskbar.java | 11 +- 5 files changed, 93 insertions(+), 63 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java index f1e67479f5..08ed60d18a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java @@ -21,6 +21,7 @@ import static com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH import android.animation.Animator; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager; import com.android.quickstep.RecentsActivity; import com.android.quickstep.fallback.RecentsState; @@ -70,12 +71,14 @@ public class FallbackTaskbarUIController extends TaskbarUIController { * Currently this animation just force stashes the taskbar in Overview. */ public Animator createAnimToRecentsState(RecentsState toState, long duration) { - boolean forceStashed = toState.hasOverviewActions(); + boolean useStashedLauncherState = toState.hasOverviewActions(); + boolean stashedLauncherState = + useStashedLauncherState && !FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get(); TaskbarStashController controller = mControllers.taskbarStashController; // Set both FLAG_IN_STASHED_LAUNCHER_STATE and FLAG_IN_APP to ensure the state is respected. // For all other states, just use the current stashed-in-app setting (e.g. if long clicked). - controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, forceStashed); - controller.updateStateForFlag(FLAG_IN_APP, !forceStashed); + controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, stashedLauncherState); + controller.updateStateForFlag(FLAG_IN_APP, !useStashedLauncherState); return controller.applyStateWithoutStart(duration); } diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 15705e7c5b..5a96d95316 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -58,7 +58,7 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine "want to switch from background to overview")) { verifyActiveContainer(); goToOverviewUnchecked(); - return mLauncher.isFallbackOverview() + return mLauncher.is3PLauncher() ? new BaseOverview(mLauncher) : new Overview(mLauncher); } } diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index 4b02ecc1f2..f23a38c3f2 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -55,7 +55,7 @@ public final class LaunchedAppState extends Background { public Taskbar getTaskbar() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get the taskbar")) { - mLauncher.waitForLauncherObject(TASKBAR_RES_ID); + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); return new Taskbar(mLauncher); } @@ -67,7 +67,7 @@ public final class LaunchedAppState extends Background { public void assertTaskbarHidden() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "waiting for taskbar to be hidden")) { - mLauncher.waitUntilLauncherObjectGone(TASKBAR_RES_ID); + mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); } } @@ -77,7 +77,7 @@ public final class LaunchedAppState extends Background { public void assertTaskbarVisible() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "waiting for taskbar to be visible")) { - mLauncher.waitForLauncherObject(TASKBAR_RES_ID); + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); } } @@ -92,7 +92,7 @@ public final class LaunchedAppState extends Background { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to show the taskbar")) { - mLauncher.waitUntilLauncherObjectGone(TASKBAR_RES_ID); + mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); final long downTime = SystemClock.uptimeMillis(); final int unstashTargetY = mLauncher.getRealDisplaySize().y @@ -106,7 +106,7 @@ public final class LaunchedAppState extends Background { LauncherInstrumentation.log("showTaskbar: sent down"); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) { - mLauncher.waitForLauncherObject(TASKBAR_RES_ID); + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, unstashTarget, LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 56ba9ea654..8f6431c549 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -555,7 +555,7 @@ public final class LauncherInstrumentation { private String getVisibleStateMessage() { if (hasLauncherObject(CONTEXT_MENU_RES_ID)) return "Context Menu"; if (hasLauncherObject(WIDGETS_RES_ID)) return "Widgets"; - if (hasLauncherObject(OVERVIEW_RES_ID)) return "Overview"; + if (hasSystemLauncherObject(OVERVIEW_RES_ID)) return "Overview"; if (hasLauncherObject(WORKSPACE_RES_ID)) return "Workspace"; if (hasLauncherObject(APPS_RES_ID)) return "AllApps"; return "LaunchedApp (" + getVisiblePackages() + ")"; @@ -760,73 +760,89 @@ public final class LauncherInstrumentation { switch (containerType) { case WORKSPACE: { waitUntilLauncherObjectGone(APPS_RES_ID); - waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + + if (is3PLauncher() && isTablet()) { + waitForSystemLauncherObject(TASKBAR_RES_ID); + } else { + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + } return waitForLauncherObject(WORKSPACE_RES_ID); } case WIDGETS: { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(APPS_RES_ID); - waitUntilLauncherObjectGone(OVERVIEW_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + + if (is3PLauncher() && isTablet()) { + waitForSystemLauncherObject(TASKBAR_RES_ID); + } else { + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + } return waitForLauncherObject(WIDGETS_RES_ID); } - case TASKBAR_ALL_APPS: - case HOME_ALL_APPS: { + case TASKBAR_ALL_APPS: { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); - waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); return waitForLauncherObject(APPS_RES_ID); } - case OVERVIEW: { + case HOME_ALL_APPS: { + waitUntilLauncherObjectGone(WORKSPACE_RES_ID); + waitUntilLauncherObjectGone(WIDGETS_RES_ID); + waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + + if (is3PLauncher() && isTablet()) { + waitForSystemLauncherObject(TASKBAR_RES_ID); + } else { + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + } + + return waitForLauncherObject(APPS_RES_ID); + } + case OVERVIEW: + case FALLBACK_OVERVIEW: { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); - return waitForLauncherObject(OVERVIEW_RES_ID); + return waitForSystemLauncherObject(OVERVIEW_RES_ID); } case SPLIT_SCREEN_SELECT: { waitUntilLauncherObjectGone(APPS_RES_ID); waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); - waitForLauncherObject(SPLIT_PLACEHOLDER_RES_ID); - return waitForLauncherObject(OVERVIEW_RES_ID); - } - case FALLBACK_OVERVIEW: { - waitUntilLauncherObjectGone(APPS_RES_ID); - waitUntilLauncherObjectGone(WORKSPACE_RES_ID); - waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(TASKBAR_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); - - return waitForFallbackLauncherObject(OVERVIEW_RES_ID); + waitForSystemLauncherObject(SPLIT_PLACEHOLDER_RES_ID); + return waitForSystemLauncherObject(OVERVIEW_RES_ID); } case LAUNCHED_APP: { waitUntilLauncherObjectGone(WORKSPACE_RES_ID); waitUntilLauncherObjectGone(APPS_RES_ID); - waitUntilLauncherObjectGone(OVERVIEW_RES_ID); waitUntilLauncherObjectGone(WIDGETS_RES_ID); - waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID); + waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); if (mIgnoreTaskbarVisibility) { return null; } - if (isTablet() && !isFallbackOverview()) { - waitForLauncherObject(TASKBAR_RES_ID); + + if (isTablet()) { + waitForSystemLauncherObject(TASKBAR_RES_ID); } else { - waitUntilLauncherObjectGone(TASKBAR_RES_ID); + waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); } return null; } @@ -957,14 +973,9 @@ public final class LauncherInstrumentation { checkForAnomaly(false, true); final Point displaySize = getRealDisplaySize(); - // The swipe up to home gesture starts from inside the launcher when the user is - // already home. Otherwise, the gesture can start inside the launcher process if the - // taskbar is visible. - boolean gestureStartFromLauncher = isTablet() - ? !isLauncher3() - || hasLauncherObject(WORKSPACE_RES_ID) - || hasLauncherObject(TASKBAR_RES_ID) - : isLauncherVisible(); + + boolean gestureStartFromLauncher = + isTablet() ? !isLauncher3() : isLauncherVisible(); // CLose floating views before going back to home. swipeUpToCloseFloatingView(gestureStartFromLauncher); @@ -997,7 +1008,7 @@ public final class LauncherInstrumentation { NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) - || hasLauncherObject(OVERVIEW_RES_ID)), + || hasSystemLauncherObject(OVERVIEW_RES_ID)), action); } try (LauncherInstrumentation.Closable c1 = addContextLayer( @@ -1053,7 +1064,8 @@ public final class LauncherInstrumentation { boolean isLauncherContainerVisible() { final String[] containerResources = {WORKSPACE_RES_ID, OVERVIEW_RES_ID, APPS_RES_ID}; - return Arrays.stream(containerResources).anyMatch(r -> hasLauncherObject(r)); + return Arrays.stream(containerResources).anyMatch( + r -> r.equals(OVERVIEW_RES_ID) ? hasSystemLauncherObject(r) : hasLauncherObject(r)); } /** @@ -1136,6 +1148,14 @@ public final class LauncherInstrumentation { waitUntilGoneBySelector(getOverviewObjectSelector(resId)); } + void waitUntilSystemLauncherObjectGone(String resId) { + if (is3PLauncher()) { + waitUntilOverviewObjectGone(resId); + } else { + waitUntilLauncherObjectGone(resId); + } + } + void waitUntilLauncherObjectGone(BySelector selector) { waitUntilGoneBySelector(makeLauncherSelector(selector)); } @@ -1266,6 +1286,11 @@ public final class LauncherInstrumentation { return mDevice.hasObject(getLauncherObjectSelector(resId)); } + private boolean hasSystemLauncherObject(String resId) { + return mDevice.hasObject(is3PLauncher() ? getOverviewObjectSelector(resId) + : getLauncherObjectSelector(resId)); + } + boolean hasLauncherObject(BySelector selector) { return mDevice.hasObject(makeLauncherSelector(selector)); } @@ -1284,6 +1309,12 @@ public final class LauncherInstrumentation { return waitForObjectBySelector(getLauncherObjectSelector(resName)); } + @NonNull + UiObject2 waitForSystemLauncherObject(String resName) { + return is3PLauncher() ? waitForOverviewObject(resName) + : waitForLauncherObject(resName); + } + @NonNull UiObject2 waitForLauncherObject(BySelector selector) { return waitForObjectBySelector(makeLauncherSelector(selector)); @@ -1294,11 +1325,6 @@ public final class LauncherInstrumentation { return tryWaitForObjectBySelector(makeLauncherSelector(selector), timeout); } - @NonNull - UiObject2 waitForFallbackLauncherObject(String resName) { - return waitForObjectBySelector(getOverviewObjectSelector(resName)); - } - @NonNull UiObject2 waitForAndroidObject(String resId) { final UiObject2 object = TestHelpers.wait( @@ -1336,7 +1362,7 @@ public final class LauncherInstrumentation { return mDevice.getLauncherPackageName(); } - boolean isFallbackOverview() { + boolean is3PLauncher() { return !getOverviewPackageName().equals(getLauncherPackageName()); } diff --git a/tests/tapl/com/android/launcher3/tapl/Taskbar.java b/tests/tapl/com/android/launcher3/tapl/Taskbar.java index 0f9d5f52c7..6ca7f4bf79 100644 --- a/tests/tapl/com/android/launcher3/tapl/Taskbar.java +++ b/tests/tapl/com/android/launcher3/tapl/Taskbar.java @@ -52,7 +52,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get a taskbar icon")) { return new TaskbarAppIcon(mLauncher, mLauncher.waitForObjectInContainer( - mLauncher.waitForLauncherObject(TASKBAR_RES_ID), + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID), AppIcon.getAppIconSelector(appName, mLauncher))); } } @@ -68,7 +68,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to hide the taskbar"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { - mLauncher.waitForLauncherObject(TASKBAR_RES_ID); + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); final long downTime = SystemClock.uptimeMillis(); Point stashTarget = new Point( @@ -79,7 +79,7 @@ public final class Taskbar { LauncherInstrumentation.log("hideTaskbar: sent down"); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) { - mLauncher.waitUntilLauncherObjectGone("taskbar_view"); + mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, stashTarget, LauncherInstrumentation.GestureScope.INSIDE); } @@ -97,7 +97,8 @@ public final class Taskbar { LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.clickLauncherObject(mLauncher.waitForObjectInContainer( - mLauncher.waitForLauncherObject(TASKBAR_RES_ID), getAllAppsButtonSelector())); + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID), + getAllAppsButtonSelector())); return new AllAppsFromTaskbar(mLauncher); } @@ -108,7 +109,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get all taskbar icons")) { return mLauncher.waitForObjectsInContainer( - mLauncher.waitForLauncherObject(TASKBAR_RES_ID), + mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID), AppIcon.getAnyAppIconSelector()) .stream() .map(UiObject2::getText)