Merge "Add TV splitscreen menu" into tm-qpr-dev
This commit is contained in:
@@ -213,13 +213,17 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
|
|||||||
mShellController.addKeyguardChangeListener(this);
|
mShellController.addKeyguardChangeListener(this);
|
||||||
if (mStageCoordinator == null) {
|
if (mStageCoordinator == null) {
|
||||||
// TODO: Multi-display
|
// TODO: Multi-display
|
||||||
mStageCoordinator = new StageCoordinator(mContext, DEFAULT_DISPLAY, mSyncQueue,
|
mStageCoordinator = createStageCoordinator();
|
||||||
|
}
|
||||||
|
mDragAndDropController.setSplitScreenController(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected StageCoordinator createStageCoordinator() {
|
||||||
|
return new StageCoordinator(mContext, DEFAULT_DISPLAY, mSyncQueue,
|
||||||
mTaskOrganizer, mDisplayController, mDisplayImeController,
|
mTaskOrganizer, mDisplayController, mDisplayImeController,
|
||||||
mDisplayInsetsController, mTransitions, mTransactionPool, mLogger,
|
mDisplayInsetsController, mTransitions, mTransactionPool, mLogger,
|
||||||
mIconProvider, mMainExecutor, mRecentTasksOptional);
|
mIconProvider, mMainExecutor, mRecentTasksOptional);
|
||||||
}
|
}
|
||||||
mDragAndDropController.setSplitScreenController(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Context getContext() {
|
public Context getContext() {
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import android.annotation.CallSuper;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.IActivityTaskManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.WindowConfiguration;
|
import android.app.WindowConfiguration;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -81,6 +82,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
@@ -244,7 +246,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StageCoordinator(Context context, int displayId, SyncTransactionQueue syncQueue,
|
protected StageCoordinator(Context context, int displayId, SyncTransactionQueue syncQueue,
|
||||||
ShellTaskOrganizer taskOrganizer, DisplayController displayController,
|
ShellTaskOrganizer taskOrganizer, DisplayController displayController,
|
||||||
DisplayImeController displayImeController,
|
DisplayImeController displayImeController,
|
||||||
DisplayInsetsController displayInsetsController, Transitions transitions,
|
DisplayInsetsController displayInsetsController, Transitions transitions,
|
||||||
@@ -880,6 +882,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
WindowContainerTransaction wct, @ExitReason int exitReason) {
|
WindowContainerTransaction wct, @ExitReason int exitReason) {
|
||||||
if (!mMainStage.isActive() || mIsExiting) return;
|
if (!mMainStage.isActive() || mIsExiting) return;
|
||||||
|
|
||||||
|
onSplitScreenExit();
|
||||||
|
|
||||||
mRecentTasks.ifPresent(recentTasks -> {
|
mRecentTasks.ifPresent(recentTasks -> {
|
||||||
// Notify recents if we are exiting in a way that breaks the pair, and disable further
|
// Notify recents if we are exiting in a way that breaks the pair, and disable further
|
||||||
// updates to splits in the recents until we enter split again
|
// updates to splits in the recents until we enter split again
|
||||||
@@ -948,6 +952,47 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden by child classes.
|
||||||
|
*/
|
||||||
|
protected void onSplitScreenEnter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden by child classes.
|
||||||
|
*/
|
||||||
|
protected void onSplitScreenExit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the split screen by finishing one of the tasks.
|
||||||
|
*/
|
||||||
|
protected void exitStage(@SplitPosition int stageToClose) {
|
||||||
|
if (ENABLE_SHELL_TRANSITIONS) {
|
||||||
|
StageTaskListener stageToTop = mSideStagePosition == stageToClose
|
||||||
|
? mMainStage
|
||||||
|
: mSideStage;
|
||||||
|
exitSplitScreen(stageToTop, EXIT_REASON_APP_FINISHED);
|
||||||
|
} else {
|
||||||
|
boolean toEnd = stageToClose == SPLIT_POSITION_BOTTOM_OR_RIGHT;
|
||||||
|
mSplitLayout.flingDividerToDismiss(toEnd, EXIT_REASON_APP_FINISHED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grants focus to the main or the side stages.
|
||||||
|
*/
|
||||||
|
protected void grantFocusToStage(@SplitPosition int stageToFocus) {
|
||||||
|
IActivityTaskManager activityTaskManagerService = IActivityTaskManager.Stub.asInterface(
|
||||||
|
ServiceManager.getService(Context.ACTIVITY_TASK_SERVICE));
|
||||||
|
try {
|
||||||
|
activityTaskManagerService.setFocusedTask(getTaskId(stageToFocus));
|
||||||
|
} catch (RemoteException | NullPointerException e) {
|
||||||
|
ProtoLog.e(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN,
|
||||||
|
"%s: Unable to update focus on the chosen stage, %s", TAG, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the split pair in the recent tasks list should be broken.
|
* Returns whether the split pair in the recent tasks list should be broken.
|
||||||
*/
|
*/
|
||||||
@@ -995,6 +1040,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
@Nullable ActivityManager.RunningTaskInfo taskInfo, @SplitPosition int startPosition) {
|
@Nullable ActivityManager.RunningTaskInfo taskInfo, @SplitPosition int startPosition) {
|
||||||
if (mMainStage.isActive()) return;
|
if (mMainStage.isActive()) return;
|
||||||
|
|
||||||
|
onSplitScreenEnter();
|
||||||
if (taskInfo != null) {
|
if (taskInfo != null) {
|
||||||
setSideStagePosition(startPosition, wct);
|
setSideStagePosition(startPosition, wct);
|
||||||
mSideStage.addTask(taskInfo, wct);
|
mSideStage.addTask(taskInfo, wct);
|
||||||
@@ -1388,6 +1434,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
}
|
}
|
||||||
} else if (isSideStage && hasChildren && !mMainStage.isActive()) {
|
} else if (isSideStage && hasChildren && !mMainStage.isActive()) {
|
||||||
// TODO (b/238697912) : Add the validation to prevent entering non-recovered status
|
// TODO (b/238697912) : Add the validation to prevent entering non-recovered status
|
||||||
|
onSplitScreenEnter();
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
mSplitLayout.init();
|
mSplitLayout.init();
|
||||||
mSplitLayout.setDividerAtBorder(mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT);
|
mSplitLayout.setDividerAtBorder(mSideStagePosition == SPLIT_POSITION_TOP_OR_LEFT);
|
||||||
|
|||||||
Reference in New Issue
Block a user