diff --git a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java index 60c7add38f..351adf4265 100644 --- a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java +++ b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java @@ -20,6 +20,8 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI import android.content.Context; +import com.android.quickstep.OverviewComponentObserver; +import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.SysUINavigationMode; import java.util.function.Predicate; @@ -35,6 +37,7 @@ public class NavigationModeFeatureFlag implements private final Supplier mBasePredicate; private final Predicate mModePredicate; private boolean mSupported; + private OverviewComponentObserver mObserver; private NavigationModeFeatureFlag(Supplier basePredicate, Predicate modePredicate) { @@ -43,12 +46,16 @@ public class NavigationModeFeatureFlag implements } public boolean get() { - return mBasePredicate.get() && mSupported; + return mBasePredicate.get() && mSupported && mObserver.isHomeAndOverviewSame(); } public void initialize(Context context) { onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context).getMode()); SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this); + + // Temporary solution to disable live tile for the fallback launcher + RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(context); + mObserver = new OverviewComponentObserver(context, rads); } @Override diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java index a412b3970f..4f27e21ae8 100644 --- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java +++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java @@ -16,7 +16,15 @@ package com.android.quickstep; +import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE; + +import static org.junit.Assert.assertTrue; + +import com.android.launcher3.Launcher; +import com.android.launcher3.tapl.LauncherInstrumentation; +import com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import com.android.launcher3.ui.AbstractLauncherUiTest; +import com.android.quickstep.views.RecentsView; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; @@ -31,4 +39,49 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { outerRule(new NavigationModeSwitchRule(mLauncher)). around(super.getRulesInsideActivityMonitor()); } + + @Override + protected void onLauncherActivityClose(Launcher launcher) { + RecentsView recentsView = launcher.getOverviewPanel(); + if (recentsView != null) { + recentsView.finishRecentsAnimation(true, null); + } + } + + @Override + protected void checkLauncherState(Launcher launcher, ContainerType expectedContainerType, + boolean isResumed, boolean isStarted) { + if (!isInLiveTileMode(launcher, expectedContainerType)) { + super.checkLauncherState(launcher, expectedContainerType, isResumed, isStarted); + } else { + assertTrue("[Live Tile] hasBeenResumed() == isStarted(), hasBeenResumed(): " + + isResumed, isResumed != isStarted); + } + } + + @Override + protected void checkLauncherStateInOverview(Launcher launcher, + ContainerType expectedContainerType, boolean isStarted, boolean isResumed) { + if (!isInLiveTileMode(launcher, expectedContainerType)) { + super.checkLauncherStateInOverview(launcher, expectedContainerType, isStarted, + isResumed); + } else { + assertTrue( + "[Live Tile] Launcher is not started or has been resumed in state: " + + expectedContainerType, + isStarted && !isResumed); + } + } + + private boolean isInLiveTileMode(Launcher launcher, + LauncherInstrumentation.ContainerType expectedContainerType) { + if (!LIVE_TILE.get() + || expectedContainerType != LauncherInstrumentation.ContainerType.OVERVIEW) { + return false; + } + + RecentsView recentsView = launcher.getOverviewPanel(); + return recentsView.getSizeStrategy().isInLiveTileMode() + && recentsView.getRunningTaskId() != -1; + } } diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java index 9732cdc64c..6e19436c90 100644 --- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java +++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java @@ -100,6 +100,7 @@ public class StartLauncherViaGestureTests extends AbstractQuickStepTest { // The test action. mLauncher.getBackground().switchToOverview(); } + closeLauncherActivity(); mLauncher.pressHome(); } } diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 0edfbeda2b..72b1d2242e 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -503,6 +503,7 @@ public abstract class AbstractLauncherUiTest { // Destroy Launcher activity. executeOnLauncher(launcher -> { if (launcher != null) { + onLauncherActivityClose(launcher); launcher.finish(); } }); @@ -524,7 +525,7 @@ public abstract class AbstractLauncherUiTest { return launcher.getAppsView().getActiveRecyclerView().getCurrentScrollY(); } - private static void checkLauncherIntegrity( + private void checkLauncherIntegrity( Launcher launcher, ContainerType expectedContainerType) { if (launcher != null) { final StateManager stateManager = launcher.getStateManager(); @@ -535,10 +536,8 @@ public abstract class AbstractLauncherUiTest { stableState == stateManager.getState()); final boolean isResumed = launcher.hasBeenResumed(); - assertTrue("hasBeenResumed() != isStarted(), hasBeenResumed(): " + isResumed, - isResumed == launcher.isStarted()); - assertTrue("hasBeenResumed() != isUserActive(), hasBeenResumed(): " + isResumed, - isResumed == launcher.isUserActive()); + final boolean isStarted = launcher.isStarted(); + checkLauncherState(launcher, expectedContainerType, isResumed, isStarted); final int ordinal = stableState.ordinal; @@ -561,8 +560,7 @@ public abstract class AbstractLauncherUiTest { break; } case OVERVIEW: { - assertTrue( - "Launcher is not resumed in state: " + expectedContainerType, + checkLauncherStateInOverview(launcher, expectedContainerType, isStarted, isResumed); assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.OVERVIEW_STATE_ORDINAL); @@ -587,4 +585,20 @@ public abstract class AbstractLauncherUiTest { expectedContainerType == ContainerType.FALLBACK_OVERVIEW); } } + + protected void checkLauncherState(Launcher launcher, ContainerType expectedContainerType, + boolean isResumed, boolean isStarted) { + assertTrue("hasBeenResumed() != isStarted(), hasBeenResumed(): " + isResumed, + isResumed == isStarted); + assertTrue("hasBeenResumed() != isUserActive(), hasBeenResumed(): " + isResumed, + isResumed == launcher.isUserActive()); + } + + protected void checkLauncherStateInOverview(Launcher launcher, + ContainerType expectedContainerType, boolean isStarted, boolean isResumed) { + assertTrue("Launcher is not resumed in state: " + expectedContainerType, + isResumed); + } + + protected void onLauncherActivityClose(Launcher launcher) { } }