Merge "Consolidate entering split screen behavior" into tm-qpr-dev
This commit is contained in:
@@ -341,6 +341,16 @@ public class RecentTasksController implements TaskStackListenerCallback,
|
|||||||
return recentTasks;
|
return recentTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the top running leaf task.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ActivityManager.RunningTaskInfo getTopRunningTask() {
|
||||||
|
List<ActivityManager.RunningTaskInfo> tasks = mActivityTaskManager.getTasks(1,
|
||||||
|
false /* filterOnlyVisibleRecents */);
|
||||||
|
return tasks.isEmpty() ? null : tasks.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the background task that match the given component.
|
* Find the background task that match the given component.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -315,10 +315,6 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
return mStageCoordinator;
|
return mStageCoordinator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActivityManager.RunningTaskInfo getFocusingTaskInfo() {
|
|
||||||
return mStageCoordinator.getFocusingTaskInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValidToEnterSplitScreen(@NonNull ActivityManager.RunningTaskInfo taskInfo) {
|
public boolean isValidToEnterSplitScreen(@NonNull ActivityManager.RunningTaskInfo taskInfo) {
|
||||||
return mStageCoordinator.isValidToEnterSplitScreen(taskInfo);
|
return mStageCoordinator.isValidToEnterSplitScreen(taskInfo);
|
||||||
}
|
}
|
||||||
@@ -628,9 +624,10 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
if (!isSplitScreenVisible()) {
|
if (!isSplitScreenVisible()) {
|
||||||
// Split screen is not yet activated, check if the current top running task is valid to
|
// Split screen is not yet activated, check if the current top running task is valid to
|
||||||
// split together.
|
// split together.
|
||||||
final ActivityManager.RunningTaskInfo taskInfo = getFocusingTaskInfo();
|
final ActivityManager.RunningTaskInfo topRunningTask = mRecentTasksOptional
|
||||||
if (taskInfo != null && isValidToEnterSplitScreen(taskInfo)) {
|
.map(recentTasks -> recentTasks.getTopRunningTask()).orElse(null);
|
||||||
return Objects.equals(taskInfo.baseIntent.getComponent(), launchingActivity);
|
if (topRunningTask != null && isValidToEnterSplitScreen(topRunningTask)) {
|
||||||
|
return Objects.equals(topRunningTask.baseIntent.getComponent(), launchingActivity);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||||
DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
|
DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
|
||||||
ShellTaskOrganizer.TaskListener, ShellTaskOrganizer.FocusListener {
|
ShellTaskOrganizer.TaskListener {
|
||||||
|
|
||||||
private static final String TAG = StageCoordinator.class.getSimpleName();
|
private static final String TAG = StageCoordinator.class.getSimpleName();
|
||||||
|
|
||||||
@@ -186,8 +186,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
private final Rect mTempRect1 = new Rect();
|
private final Rect mTempRect1 = new Rect();
|
||||||
private final Rect mTempRect2 = new Rect();
|
private final Rect mTempRect2 = new Rect();
|
||||||
|
|
||||||
private ActivityManager.RunningTaskInfo mFocusingTaskInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single-top root task which the split divider attached to.
|
* A single-top root task which the split divider attached to.
|
||||||
*/
|
*/
|
||||||
@@ -304,7 +302,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
mDisplayController.addDisplayWindowListener(this);
|
mDisplayController.addDisplayWindowListener(this);
|
||||||
mDisplayLayout = new DisplayLayout(displayController.getDisplayLayout(displayId));
|
mDisplayLayout = new DisplayLayout(displayController.getDisplayLayout(displayId));
|
||||||
transitions.addHandler(this);
|
transitions.addHandler(this);
|
||||||
mTaskOrganizer.addFocusListener(this);
|
|
||||||
mSplitUnsupportedToast = Toast.makeText(mContext,
|
mSplitUnsupportedToast = Toast.makeText(mContext,
|
||||||
R.string.dock_non_resizeble_failed_to_dock_text, Toast.LENGTH_SHORT);
|
R.string.dock_non_resizeble_failed_to_dock_text, Toast.LENGTH_SHORT);
|
||||||
}
|
}
|
||||||
@@ -455,8 +452,9 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Launches an activity into split by legacy transition. */
|
/** Launches an activity into split by legacy transition. */
|
||||||
void startIntentLegacy(PendingIntent intent, Intent fillInIntent,
|
void startIntentLegacy(PendingIntent intent, Intent fillInIntent, @SplitPosition int position,
|
||||||
@SplitPosition int position, @Nullable Bundle options) {
|
@Nullable Bundle options) {
|
||||||
|
final boolean isEnteringSplit = !isSplitActive();
|
||||||
final WindowContainerTransaction evictWct = new WindowContainerTransaction();
|
final WindowContainerTransaction evictWct = new WindowContainerTransaction();
|
||||||
prepareEvictChildTasks(position, evictWct);
|
prepareEvictChildTasks(position, evictWct);
|
||||||
|
|
||||||
@@ -466,24 +464,31 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
|
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps,
|
||||||
IRemoteAnimationFinishedCallback finishedCallback,
|
IRemoteAnimationFinishedCallback finishedCallback,
|
||||||
SurfaceControl.Transaction t) {
|
SurfaceControl.Transaction t) {
|
||||||
if (apps == null || apps.length == 0) {
|
if (isEnteringSplit) {
|
||||||
if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0) {
|
boolean openingToSide = false;
|
||||||
mMainExecutor.execute(() ->
|
if (apps != null) {
|
||||||
exitSplitScreen(mMainStage.getChildCount() == 0
|
for (int i = 0; i < apps.length; ++i) {
|
||||||
? mSideStage : mMainStage, EXIT_REASON_UNKNOWN));
|
if (apps[i].mode == MODE_OPENING
|
||||||
mSplitUnsupportedToast.show();
|
&& mSideStage.containsTask(apps[i].taskId)) {
|
||||||
}
|
openingToSide = true;
|
||||||
|
break;
|
||||||
// Do nothing when the animation was cancelled.
|
}
|
||||||
t.apply();
|
}
|
||||||
return;
|
}
|
||||||
|
if (!openingToSide) {
|
||||||
|
mMainExecutor.execute(() -> exitSplitScreen(
|
||||||
|
mSideStage.getChildCount() == 0 ? mMainStage : mSideStage,
|
||||||
|
EXIT_REASON_UNKNOWN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (apps != null) {
|
||||||
for (int i = 0; i < apps.length; ++i) {
|
for (int i = 0; i < apps.length; ++i) {
|
||||||
if (apps[i].mode == MODE_OPENING) {
|
if (apps[i].mode == MODE_OPENING) {
|
||||||
t.show(apps[i].leash);
|
t.show(apps[i].leash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
t.apply();
|
t.apply();
|
||||||
|
|
||||||
if (finishedCallback != null) {
|
if (finishedCallback != null) {
|
||||||
@@ -503,7 +508,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
|
|
||||||
// If split still not active, apply windows bounds first to avoid surface reset to
|
// If split still not active, apply windows bounds first to avoid surface reset to
|
||||||
// wrong pos by SurfaceAnimator from wms.
|
// wrong pos by SurfaceAnimator from wms.
|
||||||
if (!mMainStage.isActive() && mLogger.isEnterRequestedByDrag()) {
|
if (isEnteringSplit && mLogger.isEnterRequestedByDrag()) {
|
||||||
updateWindowBounds(mSplitLayout, wct);
|
updateWindowBounds(mSplitLayout, wct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1615,15 +1620,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
&& ArrayUtils.contains(CONTROLLED_WINDOWING_MODES, taskInfo.getWindowingMode());
|
&& ArrayUtils.contains(CONTROLLED_WINDOWING_MODES, taskInfo.getWindowingMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivityManager.RunningTaskInfo getFocusingTaskInfo() {
|
|
||||||
return mFocusingTaskInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFocusTaskChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
|
||||||
mFocusingTaskInfo = taskInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSnappedToDismiss(boolean bottomOrRight, int reason) {
|
public void onSnappedToDismiss(boolean bottomOrRight, int reason) {
|
||||||
final boolean mainStageToTop =
|
final boolean mainStageToTop =
|
||||||
|
|||||||
@@ -178,10 +178,10 @@ public class SplitScreenControllerTests extends ShellTestCase {
|
|||||||
Intent startIntent = createStartIntent("startActivity");
|
Intent startIntent = createStartIntent("startActivity");
|
||||||
PendingIntent pendingIntent =
|
PendingIntent pendingIntent =
|
||||||
PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
|
PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
|
||||||
// Put the same component into focus task
|
// Put the same component to the top running task
|
||||||
ActivityManager.RunningTaskInfo focusTaskInfo =
|
ActivityManager.RunningTaskInfo topRunningTask =
|
||||||
createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent);
|
createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent);
|
||||||
doReturn(focusTaskInfo).when(mStageCoordinator).getFocusingTaskInfo();
|
doReturn(topRunningTask).when(mRecentTasks).getTopRunningTask();
|
||||||
doReturn(true).when(mStageCoordinator).isValidToEnterSplitScreen(any());
|
doReturn(true).when(mStageCoordinator).isValidToEnterSplitScreen(any());
|
||||||
|
|
||||||
mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null);
|
mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null);
|
||||||
@@ -199,10 +199,10 @@ public class SplitScreenControllerTests extends ShellTestCase {
|
|||||||
Intent startIntent = createStartIntent("startActivity");
|
Intent startIntent = createStartIntent("startActivity");
|
||||||
PendingIntent pendingIntent =
|
PendingIntent pendingIntent =
|
||||||
PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
|
PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
|
||||||
// Put the same component into focus task
|
// Put the same component to the top running task
|
||||||
ActivityManager.RunningTaskInfo focusTaskInfo =
|
ActivityManager.RunningTaskInfo topRunningTask =
|
||||||
createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent);
|
createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent);
|
||||||
doReturn(focusTaskInfo).when(mStageCoordinator).getFocusingTaskInfo();
|
doReturn(topRunningTask).when(mRecentTasks).getTopRunningTask();
|
||||||
doReturn(true).when(mStageCoordinator).isValidToEnterSplitScreen(any());
|
doReturn(true).when(mStageCoordinator).isValidToEnterSplitScreen(any());
|
||||||
// Put the same component into a task in the background
|
// Put the same component into a task in the background
|
||||||
ActivityManager.RecentTaskInfo sameTaskInfo = new ActivityManager.RecentTaskInfo();
|
ActivityManager.RecentTaskInfo sameTaskInfo = new ActivityManager.RecentTaskInfo();
|
||||||
|
|||||||
Reference in New Issue
Block a user