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

Commit 2847f6a9 authored by Louis Chang's avatar Louis Chang Committed by Automerger Merge Worker
Browse files

[RESTRICT AUTOMERGE] Trim the activity info of another uid if no privilege am: 17df433a

parents 75aea689 17df433a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ class AppTaskImpl extends IAppTask.Stub {
                    throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
                }
                return mService.getRecentTasks().createRecentTaskInfo(task,
                        false /* stripExtras */);
                        false /* stripExtras */, true /* getTasksAllowed */);
            } finally {
                Binder.restoreCallingIdentity(origId);
            }
+6 −2
Original line number Diff line number Diff line
@@ -962,7 +962,7 @@ class RecentTasks {
                continue;
            }

            res.add(createRecentTaskInfo(task, true /* stripExtras */));
            res.add(createRecentTaskInfo(task, true /* stripExtras */, getTasksAllowed));
        }
        return res;
    }
@@ -1834,12 +1834,16 @@ class RecentTasks {
    /**
     * Creates a new RecentTaskInfo from a Task.
     */
    ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras) {
    ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras,
            boolean getTasksAllowed) {
        ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
        tr.fillTaskInfo(rti, stripExtras);
        // Fill in some deprecated values
        rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
        rti.persistentId = rti.taskId;
        if (!getTasksAllowed) {
            Task.trimIneffectiveInfo(tr, rti);
        }
        return rti;
    }

+4 −0
Original line number Diff line number Diff line
@@ -129,6 +129,10 @@ class RunningTasks {
        final RunningTaskInfo rti = task.getTaskInfo();
        // Fill in some deprecated values
        rti.id = rti.taskId;

        if (!mAllowed) {
            Task.trimIneffectiveInfo(task, rti);
        }
        return rti;
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -3653,6 +3653,27 @@ class Task extends WindowContainer<WindowContainer> {
                : SCREEN_ORIENTATION_UNSET;
    }

    /**
     * Removes the activity info if the activity belongs to a different uid, which is
     * different from the app that hosts the task.
     */
    static void trimIneffectiveInfo(Task task, TaskInfo info) {
        final ActivityRecord baseActivity = task.getActivity(r -> !r.finishing,
                false /* traverseTopToBottom */);
        final int baseActivityUid =
                baseActivity != null ? baseActivity.getUid() : task.effectiveUid;

        if (info.topActivityInfo != null
                && task.effectiveUid != info.topActivityInfo.applicationInfo.uid) {
            info.topActivity = null;
            info.topActivityInfo = null;
        }

        if (task.effectiveUid != baseActivityUid) {
            info.baseActivity = null;
        }
    }

    /**
     * Returns a {@link TaskInfo} with information from this task.
     */