From 0ea4768a022de332dde88926cf1a85ee2c7dd620 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 14 Dec 2022 16:42:10 -0800 Subject: [PATCH] Taskbar fixes when apps move to desktop and back Fixes to taskbar state when tasks are moved to desktop and fullscreen. When freeform tasks are visible and we start a new task from taskbar, it first launches in fullscreen. Transition handler in WMSHell switches it to freeform as needed. This switch causes launcher activity to be paused and then resumed. Resuming launcher activity while freeform tasks are visible, puts the launcher into an incorrect state. (Launcher should appear paused while freeform tasks are visible). When a freeform task switches to fullscreen, freeform tasks are no longer visible. This causes us to resume the launcher activity. We should not do that if a fullscreen task is visible as it puts the launcher into an incorrect state. It appears resumed even though the activity is paused. Added a check to DesktopVisibilityController that checks if the activity is actually resumed before marking it appear as resumed. Test: manual, switch a task to freeform, launch another freeform task from taskbar, taskbar should continue to be available Test: manual, switch a task to freeform, switch the task back to fullscreen, taskbar should continue to be available Bug: 261234278 Change-Id: Ia8d208619fabfcc9bffff6d8d227b236cb62a00c --- .../DesktopVisibilityController.java | 13 ++++++++++--- .../launcher3/uioverrides/QuickstepLauncher.java | 16 +++++++++++++++- .../android/quickstep/views/DesktopTaskView.java | 6 +++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java index a205d19f3c..bbc0627517 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java @@ -43,7 +43,7 @@ public class DesktopVisibilityController { */ private boolean isDesktopModeSupported() { return SystemProperties.getBoolean("persist.wm.debug.desktop_mode", false) - || SystemProperties.getBoolean("persist.wm.debug.desktop_mode_2", false); + || SystemProperties.getBoolean("persist.wm.debug.desktop_mode_2", false); } /** @@ -81,7 +81,9 @@ public class DesktopVisibilityController { StatefulActivity activity = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); View workspaceView = mLauncher.getWorkspace(); - if (activity == null || workspaceView == null || !isDesktopModeSupported()) return; + if (activity == null || workspaceView == null || !isDesktopModeSupported()) { + return; + } if (mFreeformTasksVisible) { workspaceView.setVisibility(View.INVISIBLE); @@ -93,7 +95,12 @@ public class DesktopVisibilityController { } else { workspaceView.setVisibility(View.VISIBLE); // If freeform isn't visible ensure that launcher appears resumed to behave normally. - activity.setResumed(); + // Check activity state before calling setResumed(). Launcher may have been actually + // paused (eg fullscreen task moved to front). + // In this case we should not mark the activity as resumed. + if (activity.isResumed()) { + activity.setResumed(); + } } } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 13d0be507a..462fd59507 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -96,7 +96,6 @@ import com.android.launcher3.logging.StatsLogManager.StatsLogger; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.proxy.ProxyActivityStarter; import com.android.launcher3.proxy.StartActivityParams; @@ -141,6 +140,7 @@ import com.android.quickstep.util.SplitSelectStateController; import com.android.quickstep.util.SplitToWorkspaceController; import com.android.quickstep.util.SplitWithKeyboardShortcutController; import com.android.quickstep.util.TISBindHelper; +import com.android.quickstep.views.DesktopTaskView; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -661,6 +661,20 @@ public class QuickstepLauncher extends Launcher { } } + @Override + public void setResumed() { + if (DesktopTaskView.DESKTOP_IS_PROTO2_ENABLED) { + DesktopVisibilityController controller = mDesktopVisibilityController; + if (controller != null && controller.areFreeformTasksVisible()) { + // Return early to skip setting activity to appear as resumed + // TODO(b/255649902): shouldn't be needed when we have a separate launcher state + // for desktop that we can use to control other parts of launcher + return; + } + } + super.setResumed(); + } + @Override protected void onDeferredResumed() { super.onDeferredResumed(); diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index 308249cb1e..c878278da5 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -59,10 +59,14 @@ import java.util.function.Consumer; // TODO(b/249371338): TaskView needs to be refactored to have better support for N tasks. public class DesktopTaskView extends TaskView { + /** Flag to indicate whether desktop windowing proto 2 is enabled */ + public static final boolean DESKTOP_IS_PROTO2_ENABLED = SystemProperties.getBoolean( + "persist.wm.debug.desktop_mode_2", false); + /** Flags to indicate whether desktop mode is available on the device */ public static final boolean DESKTOP_MODE_SUPPORTED = SystemProperties.getBoolean("persist.wm.debug.desktop_mode", false) - || SystemProperties.getBoolean("persist.wm.debug.desktop_mode_2", false); + || DESKTOP_IS_PROTO2_ENABLED; private static final String TAG = DesktopTaskView.class.getSimpleName();