Merge "Call exitSplitScreen() when user leaves split tasks" into sc-v2-dev

This commit is contained in:
Vinit Nayak
2021-09-09 20:19:20 +00:00
committed by Android (Google) Code Review
6 changed files with 41 additions and 9 deletions
@@ -945,6 +945,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
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
@@ -1805,8 +1806,13 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
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();
@@ -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;
}
}
@@ -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");
}
@@ -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;
}
@@ -2034,9 +2034,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
/**
* Called only when a swipe-up gesture from an app has completed. Only called after
* {@link #onGestureAnimationStart} and {@link #onGestureAnimationEnd()}.
*
* TODO(b/198310766) Need to also explicitly exit split screen if
* the swipe up was to home
*/
public void onSwipeUpAnimationSuccess() {
animateUpTaskIconScale();
@@ -99,6 +99,7 @@ import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TaskViewUtils;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.LauncherSplitScreenListener;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.util.TaskCornerRadius;
import com.android.quickstep.util.TransformParams;
@@ -693,8 +694,13 @@ public class TaskView extends FrameLayout implements Reusable {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask);
ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null);
boolean isOldTaskSplit = LauncherSplitScreenListener.INSTANCE.getNoCreate()
.getPersistentSplitIds().length > 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();