Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d689704 authored by Louis Chang's avatar Louis Chang
Browse files

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
parent 09f52aa4
Loading
Loading
Loading
Loading
+8 −11
Original line number Original line Diff line number Diff line
@@ -1261,10 +1261,13 @@ class Task extends WindowContainer<WindowContainer> {
     * @param info The activity info which could be different from {@code r.info} if set.
     * @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) {
    void setIntent(ActivityRecord r, @Nullable Intent intent, @Nullable ActivityInfo info) {
        if (this.intent == null || !mNeverRelinquishIdentity) {
            mCallingUid = r.launchedFromUid;
            mCallingUid = r.launchedFromUid;
            mCallingPackage = r.launchedFromPackage;
            mCallingPackage = r.launchedFromPackage;
            mCallingFeatureId = r.launchedFromFeatureId;
            mCallingFeatureId = r.launchedFromFeatureId;
            setIntent(intent != null ? intent : r.intent, info != null ? info : r.info);
            setIntent(intent != null ? intent : r.intent, info != null ? info : r.info);
            return;
        }
        setLockTaskAuth(r);
        setLockTaskAuth(r);
    }
    }


@@ -1272,13 +1275,7 @@ class Task extends WindowContainer<WindowContainer> {
    private void setIntent(Intent _intent, ActivityInfo info) {
    private void setIntent(Intent _intent, ActivityInfo info) {
        if (!isLeafTask()) return;
        if (!isLeafTask()) return;


        if (intent == null) {
        mNeverRelinquishIdentity = (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0;
            mNeverRelinquishIdentity =
                    (info.flags & FLAG_RELINQUISH_TASK_IDENTITY) == 0;
        } else if (mNeverRelinquishIdentity) {
            return;
        }

        affinity = info.taskAffinity;
        affinity = info.taskAffinity;
        if (intent == null) {
        if (intent == null) {
            // If this task already has an intent associated with it, don't set the root
            // If this task already has an intent associated with it, don't set the root