Merge "Allows the hierarchy operations in lock-task mode" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
96f3ac3bc2
@@ -862,22 +862,22 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
tf.getDisplayContent().setFocusedApp(targetFocus);
|
tf.getDisplayContent().setFocusedApp(targetFocus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
|
||||||
// The other operations may change task order so they are skipped while in lock
|
|
||||||
// task mode. The above operations are still allowed because they don't move
|
|
||||||
// tasks. And it may be necessary such as clearing launch root after entering
|
|
||||||
// lock task mode.
|
|
||||||
if (isInLockTaskMode) {
|
|
||||||
Slog.w(TAG, "Skip applying hierarchy operation " + hop
|
|
||||||
+ " while in lock task mode");
|
|
||||||
return effects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT: {
|
case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT: {
|
||||||
effects |= reparentChildrenTasksHierarchyOp(hop, transition, syncId);
|
effects |= reparentChildrenTasksHierarchyOp(hop, transition, syncId,
|
||||||
|
isInLockTaskMode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HIERARCHY_OP_TYPE_LAUNCH_TASK: {
|
||||||
|
mService.mAmInternal.enforceCallingPermission(START_TASKS_FROM_RECENTS,
|
||||||
|
"launchTask HierarchyOp");
|
||||||
|
final Bundle launchOpts = hop.getLaunchOptions();
|
||||||
|
final int taskId = launchOpts.getInt(
|
||||||
|
WindowContainerTransaction.HierarchyOp.LAUNCH_KEY_TASK_ID);
|
||||||
|
launchOpts.remove(WindowContainerTransaction.HierarchyOp.LAUNCH_KEY_TASK_ID);
|
||||||
|
final SafeActivityOptions safeOptions =
|
||||||
|
SafeActivityOptions.fromBundle(launchOpts, caller.mPid, caller.mUid);
|
||||||
|
waitAsyncStart(() -> mService.mTaskSupervisor.startActivityFromRecents(
|
||||||
|
caller.mPid, caller.mUid, taskId, safeOptions));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HIERARCHY_OP_TYPE_REORDER:
|
case HIERARCHY_OP_TYPE_REORDER:
|
||||||
@@ -887,6 +887,16 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
|
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// There is no use case to ask the reparent operation in lock-task mode now, so keep
|
||||||
|
// skipping this operation as usual.
|
||||||
|
if (isInLockTaskMode && type == HIERARCHY_OP_TYPE_REPARENT) {
|
||||||
|
Slog.w(TAG, "Skip applying hierarchy operation " + hop
|
||||||
|
+ " while in lock task mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isLockTaskModeViolation(wc.getParent(), wc.asTask(), isInLockTaskMode)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (syncId >= 0) {
|
if (syncId >= 0) {
|
||||||
addToSyncSet(syncId, wc);
|
addToSyncSet(syncId, wc);
|
||||||
}
|
}
|
||||||
@@ -912,19 +922,20 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
effects |= sanitizeAndApplyHierarchyOp(wc, hop);
|
effects |= sanitizeAndApplyHierarchyOp(wc, hop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HIERARCHY_OP_TYPE_LAUNCH_TASK: {
|
default: {
|
||||||
mService.mAmInternal.enforceCallingPermission(START_TASKS_FROM_RECENTS,
|
// The other operations may change task order so they are skipped while in lock
|
||||||
"launchTask HierarchyOp");
|
// task mode. The above operations are still allowed because they don't move
|
||||||
final Bundle launchOpts = hop.getLaunchOptions();
|
// tasks. And it may be necessary such as clearing launch root after entering
|
||||||
final int taskId = launchOpts.getInt(
|
// lock task mode.
|
||||||
WindowContainerTransaction.HierarchyOp.LAUNCH_KEY_TASK_ID);
|
if (isInLockTaskMode) {
|
||||||
launchOpts.remove(WindowContainerTransaction.HierarchyOp.LAUNCH_KEY_TASK_ID);
|
Slog.w(TAG, "Skip applying hierarchy operation " + hop
|
||||||
final SafeActivityOptions safeOptions =
|
+ " while in lock task mode");
|
||||||
SafeActivityOptions.fromBundle(launchOpts, caller.mPid, caller.mUid);
|
return effects;
|
||||||
waitAsyncStart(() -> mService.mTaskSupervisor.startActivityFromRecents(
|
}
|
||||||
caller.mPid, caller.mUid, taskId, safeOptions));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case HIERARCHY_OP_TYPE_PENDING_INTENT: {
|
case HIERARCHY_OP_TYPE_PENDING_INTENT: {
|
||||||
String resolvedType = hop.getActivityIntent() != null
|
String resolvedType = hop.getActivityIntent() != null
|
||||||
? hop.getActivityIntent().resolveTypeIfNeeded(
|
? hop.getActivityIntent().resolveTypeIfNeeded(
|
||||||
@@ -1103,8 +1114,25 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
return TRANSACT_EFFECTS_LIFECYCLE;
|
return TRANSACT_EFFECTS_LIFECYCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLockTaskModeViolation(WindowContainer parent, Task task,
|
||||||
|
boolean isInLockTaskMode) {
|
||||||
|
if (!isInLockTaskMode || parent == null || task == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final LockTaskController lockTaskController = mService.getLockTaskController();
|
||||||
|
boolean taskViolation = lockTaskController.isLockTaskModeViolation(task);
|
||||||
|
if (!taskViolation && parent.asTask() != null) {
|
||||||
|
taskViolation = lockTaskController.isLockTaskModeViolation(parent.asTask());
|
||||||
|
}
|
||||||
|
if (taskViolation) {
|
||||||
|
Slog.w(TAG, "Can't support the operation since in lock task mode violation. "
|
||||||
|
+ " Task: " + task + " Parent : " + parent);
|
||||||
|
}
|
||||||
|
return taskViolation;
|
||||||
|
}
|
||||||
|
|
||||||
private int reparentChildrenTasksHierarchyOp(WindowContainerTransaction.HierarchyOp hop,
|
private int reparentChildrenTasksHierarchyOp(WindowContainerTransaction.HierarchyOp hop,
|
||||||
@Nullable Transition transition, int syncId) {
|
@Nullable Transition transition, int syncId, boolean isInLockTaskMode) {
|
||||||
WindowContainer<?> currentParent = hop.getContainer() != null
|
WindowContainer<?> currentParent = hop.getContainer() != null
|
||||||
? WindowContainer.fromBinder(hop.getContainer()) : null;
|
? WindowContainer.fromBinder(hop.getContainer()) : null;
|
||||||
WindowContainer newParent = hop.getNewParent() != null
|
WindowContainer newParent = hop.getNewParent() != null
|
||||||
@@ -1142,6 +1170,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
? newParent.asTask().getDisplayArea()
|
? newParent.asTask().getDisplayArea()
|
||||||
: newParent.asTaskDisplayArea();
|
: newParent.asTaskDisplayArea();
|
||||||
final WindowContainer finalCurrentParent = currentParent;
|
final WindowContainer finalCurrentParent = currentParent;
|
||||||
|
final WindowContainer finalNewParent = newParent;
|
||||||
Slog.i(TAG, "reparentChildrenTasksHierarchyOp"
|
Slog.i(TAG, "reparentChildrenTasksHierarchyOp"
|
||||||
+ " currentParent=" + currentParent + " newParent=" + newParent + " hop=" + hop);
|
+ " currentParent=" + currentParent + " newParent=" + newParent + " hop=" + hop);
|
||||||
|
|
||||||
@@ -1165,6 +1194,9 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
|| !ArrayUtils.contains(hop.getWindowingModes(), task.getWindowingMode())) {
|
|| !ArrayUtils.contains(hop.getWindowingModes(), task.getWindowingMode())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (isLockTaskModeViolation(finalNewParent, task, isInLockTaskMode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (hop.getToTop()) {
|
if (hop.getToTop()) {
|
||||||
tasksToReparent.add(0, task);
|
tasksToReparent.add(0, task);
|
||||||
|
|||||||
Reference in New Issue
Block a user