From eb143041fae0023a0041f6685a0f9f258f9524ac Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Mon, 25 Sep 2023 13:31:47 -0700 Subject: [PATCH 1/2] Enable live tile for desktop Remove logic to always screenshot desktop tasks. Bug: 297590571 Test: swipe up to recents when on desktop Change-Id: Ie6e95f711e1721f66a2ed6081fe99d941c18b393 --- .../com/android/quickstep/AbsSwipeUpHandler.java | 15 +++------------ .../android/quickstep/TaskAnimationManager.java | 7 ------- .../android/quickstep/views/DesktopTaskView.java | 8 ++++---- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index e788cc42ad..4dfa81dd4e 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -2084,18 +2084,9 @@ public abstract class AbsSwipeUpHandler, } private void finishCurrentTransitionToRecents() { - if (mRecentsView != null - && mActivityInterface.getDesktopVisibilityController() != null - && mActivityInterface.getDesktopVisibilityController().areFreeformTasksVisible()) { - mRecentsView.switchToScreenshot(() -> { - mRecentsView.finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, - () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); - }); - } else { - mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); - if (mRecentsAnimationController != null) { - mRecentsAnimationController.detachNavigationBarFromApp(true); - } + mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); + if (mRecentsAnimationController != null) { + mRecentsAnimationController.detachNavigationBarFromApp(true); } } diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index f5a7eccff1..dbd1ea3584 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -42,7 +42,6 @@ import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.quickstep.TopTaskTracker.CachedTaskInfo; import com.android.quickstep.util.ActiveGestureLog; -import com.android.quickstep.views.DesktopTaskView; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -261,12 +260,6 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn // to let the transition controller collect Home activity. CachedTaskInfo cti = gestureState.getRunningTask(); boolean homeIsOnTop = cti != null && cti.isHomeTask(); - if (DesktopTaskView.DESKTOP_MODE_SUPPORTED) { - if (cti != null && cti.isFreeformTask()) { - // No transient launch when desktop task is on top - homeIsOnTop = true; - } - } if (activityInterface.allowAllAppsFromOverview()) { homeIsOnTop = true; } diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index dc6b5a2a47..9ff990e24a 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -18,7 +18,6 @@ package com.android.quickstep.views; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; -import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; import android.content.Context; @@ -41,7 +40,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.desktop.DesktopRecentsTransitionController; @@ -338,16 +336,18 @@ public class DesktopTaskView extends TaskView { @Override public RunnableList launchTaskAnimated() { RunnableList endCallback = new RunnableList(); - endCallback.add(() -> Launcher.getLauncher(mActivity).getStateManager().goToState(NORMAL)); + RecentsView recentsView = getRecentsView(); DesktopRecentsTransitionController recentsController = - getRecentsView().getDesktopRecentsController(); + recentsView.getDesktopRecentsController(); if (recentsController != null) { recentsController.launchDesktopFromRecents(this, success -> { endCallback.executeAllAndDestroy(); }); } + // Callbacks get run from recentsView for case when recents animation already running + recentsView.addSideTaskLaunchCallback(endCallback); return endCallback; } From 0927251a7b5d6669e2cd78882a895f4d800b3084 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Thu, 5 Oct 2023 15:48:24 -0700 Subject: [PATCH 2/2] Account for freeform tasks being visible in overview When live tiles are enabled, desktop tasks remain visible while in overview. This is due to tasks remaining in running state. Update DesktopVsibilityController to handle this case. If in freeform, it should return that freeform tasks are not visible to any callers. Also move launcher state handling to inside the controller so we don't have this handling in other places. Introduce separate handling of background and overview state. In background state we want to keep the freeform task visibility state matching the actualy visibility. And show the launcher views and resume the activity. In overview state we want to override the freeform visibility and show launcher views. Bug: 297590571 Test: open an app on desktop - swipe up for taskbar multiple times, observe that we remain on desktop - swipe up for taskbar and launch an app, observe it launches on desktop - swipe up to recents, observe that recents UI is shown and task remains running - swipe up to recents, launch desktop again from recents - swipe up to recents, launch another fullscreen app from recents - swipe up from a fullscreen, launch desktop from recents Change-Id: Id5cef7111da6929c8435ef9d221db1abd8361b15 --- .../DesktopVisibilityController.java | 67 +++++++++++++++---- .../quickstep/views/LauncherRecentsView.java | 23 ++----- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java index 42e6809ac5..00a282ad90 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java @@ -15,8 +15,10 @@ */ package com.android.launcher3.statehandlers; +import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; +import android.os.Debug; import android.os.SystemProperties; import android.util.Log; import android.view.View; @@ -46,6 +48,7 @@ public class DesktopVisibilityController { private boolean mFreeformTasksVisible; private boolean mInOverviewState; + private boolean mBackgroundStateEnabled; private boolean mGestureInProgress; @Nullable @@ -113,7 +116,11 @@ public class DesktopVisibilityController { * Whether freeform windows are visible in desktop mode. */ public boolean areFreeformTasksVisible() { - return mFreeformTasksVisible; + if (DEBUG) { + Log.d(TAG, "areFreeformTasksVisible: freeformVisible=" + mFreeformTasksVisible + + " overview=" + mInOverviewState); + } + return mFreeformTasksVisible && !mInOverviewState; } /** @@ -121,7 +128,8 @@ public class DesktopVisibilityController { */ public void setFreeformTasksVisible(boolean freeformTasksVisible) { if (DEBUG) { - Log.d(TAG, "setFreeformTasksVisible: visible=" + freeformTasksVisible); + Log.d(TAG, "setFreeformTasksVisible: visible=" + freeformTasksVisible + + " currentValue=" + mFreeformTasksVisible); } if (!isDesktopModeSupported()) { return; @@ -146,11 +154,21 @@ public class DesktopVisibilityController { } /** - * Sets whether the overview is visible and updates launcher visibility based on that. + * Process launcher state change and update launcher view visibility based on desktop state */ - public void setOverviewStateEnabled(boolean overviewStateEnabled) { + public void onLauncherStateChanged(LauncherState state) { if (DEBUG) { - Log.d(TAG, "setOverviewStateEnabled: enabled=" + overviewStateEnabled); + Log.d(TAG, "onLauncherStateChanged: newState=" + state); + } + setBackgroundStateEnabled(state == BACKGROUND_APP); + // Desktop visibility tracks overview and background state separately + setOverviewStateEnabled(state != BACKGROUND_APP && state.overviewUi); + } + + private void setOverviewStateEnabled(boolean overviewStateEnabled) { + if (DEBUG) { + Log.d(TAG, "setOverviewStateEnabled: enabled=" + overviewStateEnabled + + " currentValue=" + mInOverviewState); } if (!isDesktopModeSupported()) { return; @@ -160,7 +178,7 @@ public class DesktopVisibilityController { if (mInOverviewState) { setLauncherViewsVisibility(View.VISIBLE); markLauncherResumed(); - } else if (mFreeformTasksVisible && !mGestureInProgress) { + } else if (areFreeformTasksVisible() && !mGestureInProgress) { // Switching out of overview state and gesture finished. // If freeform tasks are still visible, hide launcher again. setLauncherViewsVisibility(View.INVISIBLE); @@ -169,6 +187,27 @@ public class DesktopVisibilityController { } } + private void setBackgroundStateEnabled(boolean backgroundStateEnabled) { + if (DEBUG) { + Log.d(TAG, "setBackgroundStateEnabled: enabled=" + backgroundStateEnabled + + " currentValue=" + mBackgroundStateEnabled); + } + if (!isDesktopModeSupported()) { + return; + } + if (backgroundStateEnabled != mBackgroundStateEnabled) { + mBackgroundStateEnabled = backgroundStateEnabled; + if (mBackgroundStateEnabled) { + setLauncherViewsVisibility(View.VISIBLE); + markLauncherResumed(); + } else if (areFreeformTasksVisible() && !mGestureInProgress) { + // Switching out of background state. If freeform tasks are visible, pause launcher. + setLauncherViewsVisibility(View.INVISIBLE); + markLauncherPaused(); + } + } + } + /** * Whether recents gesture is currently in progress. */ @@ -183,6 +222,9 @@ public class DesktopVisibilityController { if (!isDesktopModeSupported()) { return; } + if (DEBUG) { + Log.d(TAG, "setRecentsGestureStart"); + } setRecentsGestureInProgress(true); } @@ -194,6 +236,9 @@ public class DesktopVisibilityController { if (!isDesktopModeSupported()) { return; } + if (DEBUG) { + Log.d(TAG, "setRecentsGestureEnd: endTarget=" + endTarget); + } setRecentsGestureInProgress(false); if (endTarget == null) { @@ -203,9 +248,6 @@ public class DesktopVisibilityController { } private void setRecentsGestureInProgress(boolean gestureInProgress) { - if (DEBUG) { - Log.d(TAG, "setGestureInProgress: inProgress=" + gestureInProgress); - } if (gestureInProgress != mGestureInProgress) { mGestureInProgress = gestureInProgress; } @@ -222,7 +264,8 @@ public class DesktopVisibilityController { private void setLauncherViewsVisibility(int visibility) { if (DEBUG) { - Log.d(TAG, "setLauncherViewsVisibility: visibility=" + visibility); + Log.d(TAG, "setLauncherViewsVisibility: visibility=" + visibility + " " + + Debug.getCaller()); } View workspaceView = mLauncher.getWorkspace(); if (workspaceView != null) { @@ -236,7 +279,7 @@ public class DesktopVisibilityController { private void markLauncherPaused() { if (DEBUG) { - Log.d(TAG, "markLauncherPaused"); + Log.d(TAG, "markLauncherPaused " + Debug.getCaller()); } StatefulActivity activity = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); @@ -247,7 +290,7 @@ public class DesktopVisibilityController { private void markLauncherResumed() { if (DEBUG) { - Log.d(TAG, "markLauncherResumed"); + Log.d(TAG, "markLauncherResumed " + Debug.getCaller()); } StatefulActivity activity = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 1867fe90e3..fb9e640766 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -137,16 +137,16 @@ public class LauncherRecentsView extends RecentsView remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true)); } - - if (!finalState.overviewUi) { - // If overview is disabled, we want to update at the end - updateOverviewStateForDesktop(false); - } } @Override @@ -183,9 +178,6 @@ public class LauncherRecentsView extends RecentsView