From f666e494afccaa6c2db112798f5442efeb3881ee Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Tue, 19 Jan 2021 12:06:50 +0800 Subject: [PATCH] Prevent set intent on non-leaf tasks The root task was created with null intent, but the intent, resize mode and other information were updated from child tasks, which sets the split-screen-secondary root task to unresizeable. Bug: 170801863 Test: presubmit Change-Id: I57458c05c4c579d78894869c0590788d17912bc3 --- .../android/server/windowmanagerservice.proto | 1 + .../core/java/com/android/server/wm/Task.java | 17 ++++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto index 610e0e0b4b89f..859207e08d414 100644 --- a/core/proto/android/server/windowmanagerservice.proto +++ b/core/proto/android/server/windowmanagerservice.proto @@ -307,6 +307,7 @@ message TaskProto { optional bool animating_bounds = 26 [deprecated = true]; optional float minimize_amount = 27; optional bool created_by_organizer = 28; + optional string affinity = 29; } /* represents ActivityRecordProto */ diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 79d112385d672..ec1588d153206 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -124,6 +124,7 @@ import static com.android.server.wm.Task.ActivityState.RESUMED; import static com.android.server.wm.Task.ActivityState.STARTED; import static com.android.server.wm.Task.ActivityState.STOPPING; import static com.android.server.wm.TaskProto.ACTIVITY_TYPE; +import static com.android.server.wm.TaskProto.AFFINITY; import static com.android.server.wm.TaskProto.BOUNDS; import static com.android.server.wm.TaskProto.CREATED_BY_ORGANIZER; import static com.android.server.wm.TaskProto.DISPLAY_ID; @@ -1244,27 +1245,20 @@ class Task extends WindowContainer { mCallingFeatureId = r.launchedFromFeatureId; setIntent(intent != null ? intent : r.intent, info != null ? info : r.info); setLockTaskAuth(r); - - final WindowContainer parent = getParent(); - if (parent != null) { - final Task t = parent.asTask(); - if (t != null) { - t.setIntent(r); - } - } } /** Sets the original intent, _without_ updating the calling uid or package. */ private void setIntent(Intent _intent, ActivityInfo info) { - final boolean isLeaf = isLeafTask(); + if (!isLeafTask()) return; + if (intent == null) { mNeverRelinquishIdentity = (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0; - } else if (mNeverRelinquishIdentity && isLeaf) { + } else if (mNeverRelinquishIdentity) { return; } - affinity = isLeaf ? info.taskAffinity : null; + affinity = info.taskAffinity; if (intent == null) { // If this task already has an intent associated with it, don't set the root // affinity -- we don't want it changing after initially set, but the initially @@ -7809,6 +7803,7 @@ class Task extends WindowContainer { } proto.write(CREATED_BY_ORGANIZER, mCreatedByOrganizer); + proto.write(AFFINITY, affinity); proto.end(token); }