From 6abaca4e036b57cc8f818c55ad996e191cb7fea9 Mon Sep 17 00:00:00 2001 From: Randy Pfohl Date: Wed, 9 Apr 2025 22:48:56 +0000 Subject: [PATCH 1/2] 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()) From b0487db434d41e738afc8f0c3538cd597a1e27ee Mon Sep 17 00:00:00 2001 From: Randy Pfohl Date: Wed, 9 Apr 2025 22:49:17 +0000 Subject: [PATCH 2/2] fixing splitview issue not receiving callback in recents in window Test: Built and ran locally. Verified cycling back to default state. Flag: com.android.launcher3.enable_fallback_overview_in_window com.android.launcher3.enable_launcher_overview_in_window Bug: 292269949 Change-Id: I3054ef815baf1a852c365a07cad5e66a168f88c5 --- .../quickstep/fallback/window/RecentsWindowManager.kt | 2 -- .../src/com/android/quickstep/views/RecentsView.java | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt index 0d04dec1f8..613ca3969b 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt @@ -87,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 diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index fd215674d1..e5507603ae 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -201,6 +201,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; @@ -5503,6 +5504,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) {