From 1d6897040099570cbce5c2540418f5c88ca54963 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Wed, 24 Feb 2021 14:28:24 +0800 Subject: Do not update calling pid/uid if the task cannot be relinquished The calling pid/uid was updated by the new task root activity while the original task root activity finished. Since the updated uid doesn't have the Uri permission to restart the task, so user cannot launch the task from Recents. Bug: 156335070 Test: atest RecentTasksTest, start tasks from Recents Change-Id: Idc7d9ba03b0eea4e2ba979ab65a79b0f1e5b272a --- services/core/java/com/android/server/wm/Task.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 29c7ff118595..6547e06e067f 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1261,10 +1261,13 @@ class Task extends WindowContainer { * @param info The activity info which could be different from {@code r.info} if set. */ void setIntent(ActivityRecord r, @Nullable Intent intent, @Nullable ActivityInfo info) { - mCallingUid = r.launchedFromUid; - mCallingPackage = r.launchedFromPackage; - mCallingFeatureId = r.launchedFromFeatureId; - setIntent(intent != null ? intent : r.intent, info != null ? info : r.info); + if (this.intent == null || !mNeverRelinquishIdentity) { + mCallingUid = r.launchedFromUid; + mCallingPackage = r.launchedFromPackage; + mCallingFeatureId = r.launchedFromFeatureId; + setIntent(intent != null ? intent : r.intent, info != null ? info : r.info); + return; + } setLockTaskAuth(r); } @@ -1272,13 +1275,7 @@ class Task extends WindowContainer { private void setIntent(Intent _intent, ActivityInfo info) { if (!isLeafTask()) return; - if (intent == null) { - mNeverRelinquishIdentity = - (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0; - } else if (mNeverRelinquishIdentity) { - return; - } - + mNeverRelinquishIdentity = (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0; affinity = info.taskAffinity; if (intent == null) { // If this task already has an intent associated with it, don't set the root -- cgit v1.2.3-59-g8ed1b