diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 9ebbb9b0fa..6b16d0bf2e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -865,10 +865,11 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, if (overviewCommandHelper != null) { overviewCommandHelper.clearPendingCommands(); } + PerDisplayRepository recentsWindowManagerRepository = RecentsWindowManager.REPOSITORY_INSTANCE.get(this); recentsWindowManagerRepository.forEach(/* createIfAbsent= */ true, recentsWindowManager -> { - recentsWindowManager.onNewIntent(); + recentsWindowManager.cleanupRecentsWindow(); }); } diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt index 91ab561b47..613ca3969b 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt @@ -39,7 +39,7 @@ import com.android.launcher3.AbstractFloatingView import com.android.launcher3.BaseActivity import com.android.launcher3.LauncherAnimationRunner import com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory -import com.android.launcher3.LauncherState +import com.android.launcher3.LauncherState.NORMAL import com.android.launcher3.R import com.android.launcher3.compat.AccessibilityManagerCompat import com.android.launcher3.dagger.DisplayContext @@ -59,6 +59,7 @@ import com.android.launcher3.util.SystemUiController import com.android.launcher3.util.WallpaperColorHints import com.android.launcher3.views.BaseDragLayer import com.android.launcher3.views.ScrimView +import com.android.quickstep.HomeVisibilityState import com.android.quickstep.OverviewComponentObserver import com.android.quickstep.RecentsAnimationCallbacks import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener @@ -86,8 +87,6 @@ import com.android.quickstep.views.OverviewActionsView import com.android.quickstep.views.RecentsView import com.android.quickstep.views.RecentsViewContainer import com.android.systemui.shared.recents.model.ThumbnailData -import com.android.systemui.shared.system.TaskStackChangeListener -import com.android.systemui.shared.system.TaskStackChangeListeners import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject @@ -194,10 +193,11 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints TestLogging.recordEvent(SEQUENCE_MAIN, "onBackInvoked") } - private val taskStackChangeListener = - object : TaskStackChangeListener { - override fun onTaskMovedToFront(taskId: Int) { - if ((isShowing() && isInState(DEFAULT))) { + private val homeVisibilityState = SystemUiProxy.INSTANCE.get(this).homeVisibilityState + private val homeVisibilityListener = + object : HomeVisibilityState.VisibilityChangeListener { + override fun onHomeVisibilityChanged(isVisible: Boolean) { + if (isShowing() && !isVisible && isInState(DEFAULT)) { // handling state where we end recents animation by swiping livetile away // TODO: animate this switch. cleanupRecentsWindow() @@ -217,7 +217,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints } init { - TaskStackChangeListeners.getInstance().registerTaskStackListener(taskStackChangeListener) + homeVisibilityState.addListener(homeVisibilityListener) } override fun handleConfigurationChanged(configuration: Configuration?) { @@ -234,8 +234,8 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints super.destroy() Executors.MAIN_EXECUTOR.execute { onViewDestroyed() } cleanupRecentsWindow() - TaskStackChangeListeners.getInstance().unregisterTaskStackListener(taskStackChangeListener) callbacks?.removeListener(recentsAnimationListener) + homeVisibilityState.removeListener(homeVisibilityListener) recentsWindowTracker.onContextDestroyed(this) recentsView?.destroy() } @@ -325,11 +325,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints stateManager.moveToRestState() } - fun onNewIntent() { - cleanupRecentsWindow() - } - - private fun cleanupRecentsWindow() { + fun cleanupRecentsWindow() { RecentsWindowProtoLogProxy.logCleanup(isShowing()) if (isShowing()) { windowManager.removeViewImmediate(windowView) @@ -389,7 +385,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints override fun onStateSetEnd(state: RecentsState) { super.onStateSetEnd(state) RecentsWindowProtoLogProxy.logOnStateSetEnd(state.toString()) - if (state.toLauncherState() == LauncherState.NORMAL) { + if (state.toLauncherState() == NORMAL) { cleanupRecentsWindow() } AccessibilityManagerCompat.sendStateEventToTest(baseContext, state.toLauncherStateOrdinal()) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 41680516b4..c08e0b819d 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -200,6 +200,7 @@ import com.android.quickstep.TaskViewUtils; import com.android.quickstep.TopTaskTracker; import com.android.quickstep.ViewUtils; import com.android.quickstep.fallback.window.RecentsWindowFlags; +import com.android.quickstep.fallback.window.RecentsWindowManager; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import com.android.quickstep.recents.data.AppTimersRepository; import com.android.quickstep.recents.data.AppTimersRepositoryImpl; @@ -5499,6 +5500,13 @@ public abstract class RecentsView< } mSplitHiddenTaskView = null; } + + if (RecentsWindowFlags.getEnableOverviewInWindow()) { + // Recents doesn't receive activity callback, so we cleanup manually + if (mContainer instanceof RecentsWindowManager manager) { + manager.cleanupRecentsWindow(); + } + } } private void safeRemoveDragLayerView(@Nullable View viewToRemove) {