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
This commit is contained in:
Louis Chang
2021-02-24 14:28:24 +08:00
parent 09f52aa440
commit 1d68970400

View File

@@ -1261,10 +1261,13 @@ class Task extends WindowContainer<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<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