From 6abaca4e036b57cc8f818c55ad996e191cb7fea9 Mon Sep 17 00:00:00 2001 From: Randy Pfohl Date: Wed, 9 Apr 2025 22:48:56 +0000 Subject: [PATCH] Moving RecentsWindowManager away from taskstackchangelistener Test: Built and ran locally, tested against various cases, verified with logs Flag: com.android.launcher3.enable_fallback_overview_in_window com.android.launcher3.enable_launcher_overview_in_window Bug: 292269949 Change-Id: If90b1f98ad18286fa0c9b9625077237823197967 --- .../uioverrides/QuickstepLauncher.java | 3 ++- .../fallback/window/RecentsWindowManager.kt | 24 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) 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..0d04dec1f8 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 @@ -194,10 +195,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 +219,7 @@ constructor(@Assisted context: Context, wallpaperColorHints: WallpaperColorHints } init { - TaskStackChangeListeners.getInstance().registerTaskStackListener(taskStackChangeListener) + homeVisibilityState.addListener(homeVisibilityListener) } override fun handleConfigurationChanged(configuration: Configuration?) { @@ -234,8 +236,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 +327,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 +387,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())