diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index be0c980219..627dd64827 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -942,6 +942,7 @@ public abstract class AbsSwipeUpHandler, mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT); // Notify swipe-to-home (recents animation) is finished SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished(); + LauncherSplitScreenListener.INSTANCE.getNoCreate().notifySwipingToHome(); break; case RECENTS: mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT @@ -1802,8 +1803,13 @@ public abstract class AbsSwipeUpHandler, mGestureState.updateLastStartedTaskId(taskId); boolean hasTaskPreviouslyAppeared = mGestureState.getPreviouslyAppearedTaskIds() .contains(taskId); + boolean isOldTaskSplit = LauncherSplitScreenListener.INSTANCE.getNoCreate() + .getRunningSplitTaskIds().length > 0; nextTask.launchTask(success -> { resultCallback.accept(success); + if (isOldTaskSplit) { + SystemUiProxy.INSTANCE.getNoCreate().exitSplitScreen(taskId); + } if (success) { if (hasTaskPreviouslyAppeared) { onRestartPreviouslyAppearedTask(); diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 8fb851c399..b2324640e5 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -32,6 +32,7 @@ import androidx.annotation.UiThread; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.util.RunnableList; import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener; +import com.android.quickstep.util.LauncherSplitScreenListener; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.ThumbnailData; @@ -157,6 +158,7 @@ public class OverviewCommandHelper { } if (cmd.type == TYPE_HOME) { mService.startActivity(mOverviewComponentObserver.getHomeIntent()); + LauncherSplitScreenListener.INSTANCE.getNoCreate().notifySwipingToHome(); return true; } } else { @@ -175,6 +177,7 @@ public class OverviewCommandHelper { return launchTask(recents, getNextTask(recents), cmd); case TYPE_HOME: recents.startHome(); + LauncherSplitScreenListener.INSTANCE.getNoCreate().notifySwipingToHome(); return true; } } diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 7d2d41326c..aea2d4c645 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -533,10 +533,17 @@ public class SystemUiProxy implements ISystemUiProxy, } } - public void exitSplitScreen() { + /** + * To be called whenever the user exits out of split screen apps (either by launching another + * app or by swiping home) + * @param topTaskId The taskId of the new app that was launched. System will then move this task + * to the front of what the user sees while removing all other split stages. + * If swiping to home (or there is no task to put at the top), can pass in -1. + */ + public void exitSplitScreen(int topTaskId) { if (mSplitScreen != null) { try { - mSplitScreen.exitSplitScreen(); + mSplitScreen.exitSplitScreen(topTaskId); } catch (RemoteException e) { Log.w(TAG, "Failed call exitSplitScreen"); } diff --git a/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java b/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java index 0f4ed014f0..fa4cddc426 100644 --- a/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java +++ b/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java @@ -44,8 +44,6 @@ public class LauncherSplitScreenListener extends ISplitScreenListener.Stub { if (frozen) { mPersistentGroupedIds = getRunningSplitTaskIds(); } else { - // TODO(b/198310766) Need to also explicitly exit split screen if - // we're not currently viewing split screened apps mPersistentGroupedIds = EMPTY_ARRAY; } } @@ -53,8 +51,11 @@ public class LauncherSplitScreenListener extends ISplitScreenListener.Stub { /** * Gets set to current split taskIDs whenever the task list is frozen, and set to empty array - * whenever task list unfreezes. - * When not null, this indicates that we need to load a GroupedTaskView as the most recent + * whenever task list unfreezes. This also gets set to empty array whenever the user swipes to + * home - in that case the task list does not unfreeze immediately after the gesture, so it's + * done via {@link #notifySwipingToHome()}. + * + * When not empty, this indicates that we need to load a GroupedTaskView as the most recent * page, so user can quickswitch back to a grouped task. */ private int[] mPersistentGroupedIds; @@ -140,6 +141,18 @@ public class LauncherSplitScreenListener extends ISplitScreenListener.Stub { } } + /** Notifies SystemUi to remove any split screen state */ + public void notifySwipingToHome() { + boolean hasSplitTasks = LauncherSplitScreenListener.INSTANCE.getNoCreate() + .getPersistentSplitIds().length > 0; + if (!hasSplitTasks) { + return; + } + + SystemUiProxy.INSTANCE.getNoCreate().exitSplitScreen(-1); + mPersistentGroupedIds = EMPTY_ARRAY; + } + private void resetTaskId(StagedSplitTaskPosition taskPosition) { taskPosition.taskId = -1; } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index b690982efb..192cef80a9 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2001,9 +2001,6 @@ public abstract class RecentsView 0; if (ActivityManagerWrapper.getInstance() .startActivityFromRecents(mTask.key, opts.options)) { + if (isOldTaskSplit) { + SystemUiProxy.INSTANCE.getNoCreate().exitSplitScreen(mTask.key.id); + } RecentsView recentsView = getRecentsView(); if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskViewId() != -1) { recentsView.onTaskLaunchedInLiveTileMode();