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/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; } 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