Revert "[RESTRICT AUTOMERGE] Trim the activity info of another uid if no privilege"

This reverts commit 9c19841384.

Reason for revert: apps crashed due to the top activity info trimmed

Bug: 264269392 263434196 263438172
Change-Id: I45d89ed787a97fb836c9dd0cab035c427f9405a7
This commit is contained in:
Louis Chang
2023-01-04 04:59:56 +00:00
parent 9c19841384
commit 53a76608e5
4 changed files with 5 additions and 47 deletions

View File

@@ -84,8 +84,7 @@ class AppTaskImpl extends IAppTask.Stub {
if (tr == null) { if (tr == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId); throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
} }
return mService.getRecentTasks().createRecentTaskInfo(tr, return mService.getRecentTasks().createRecentTaskInfo(tr);
true /* getTasksAllowed */);
} finally { } finally {
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
} }

View File

@@ -944,7 +944,7 @@ class RecentTasks {
continue; continue;
} }
final ActivityManager.RecentTaskInfo rti = createRecentTaskInfo(tr, getTasksAllowed); final ActivityManager.RecentTaskInfo rti = createRecentTaskInfo(tr);
if (!getDetailedTasks) { if (!getDetailedTasks) {
rti.baseIntent.replaceExtras((Bundle) null); rti.baseIntent.replaceExtras((Bundle) null);
} }
@@ -1715,15 +1715,12 @@ class RecentTasks {
/** /**
* Creates a new RecentTaskInfo from a TaskRecord. * Creates a new RecentTaskInfo from a TaskRecord.
*/ */
ActivityManager.RecentTaskInfo createRecentTaskInfo(TaskRecord tr, boolean getTasksAllowed) { ActivityManager.RecentTaskInfo createRecentTaskInfo(TaskRecord tr) {
ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
tr.fillTaskInfo(rti); tr.fillTaskInfo(rti);
// Fill in some deprecated values // Fill in some deprecated values
rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID; rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
rti.persistentId = rti.taskId; rti.persistentId = rti.taskId;
if (!getTasksAllowed) {
TaskRecord.trimIneffectiveInfo(tr, rti);
}
return rti; return rti;
} }

View File

@@ -68,7 +68,7 @@ class RunningTasks {
} }
final TaskRecord task = iter.next(); final TaskRecord task = iter.next();
list.add(createRunningTaskInfo(task, allowed)); list.add(createRunningTaskInfo(task));
maxNum--; maxNum--;
} }
} }
@@ -76,15 +76,11 @@ class RunningTasks {
/** /**
* Constructs a {@link RunningTaskInfo} from a given {@param task}. * Constructs a {@link RunningTaskInfo} from a given {@param task}.
*/ */
private RunningTaskInfo createRunningTaskInfo(TaskRecord task, boolean allowed) { private RunningTaskInfo createRunningTaskInfo(TaskRecord task) {
final RunningTaskInfo rti = new RunningTaskInfo(); final RunningTaskInfo rti = new RunningTaskInfo();
task.fillTaskInfo(rti); task.fillTaskInfo(rti);
// Fill in some deprecated values // Fill in some deprecated values
rti.id = rti.taskId; rti.id = rti.taskId;
if (!allowed) {
TaskRecord.trimIneffectiveInfo(task, rti);
}
return rti; return rti;
} }
} }

View File

@@ -2436,40 +2436,6 @@ class TaskRecord extends ConfigurationContainer {
info.configuration.setTo(getConfiguration()); info.configuration.setTo(getConfiguration());
} }
/**
* 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(TaskRecord task, TaskInfo info) {
int topActivityUid = task.effectiveUid;
for (int i = task.mActivities.size() - 1; i >= 0; --i) {
final ActivityRecord r = task.mActivities.get(i);
if (r.finishing || r.isState(ActivityState.INITIALIZING)) {
continue;
}
topActivityUid = r.info.applicationInfo.uid;
break;
}
if (task.effectiveUid != topActivityUid) {
info.topActivity = null;
}
int baseActivityUid = task.effectiveUid;
for (int i = 0; i < task.mActivities.size(); ++i) {
final ActivityRecord r = task.mActivities.get(i);
if (r.finishing) {
continue;
}
baseActivityUid = r.info.applicationInfo.uid;
break;
}
if (task.effectiveUid != baseActivityUid) {
info.baseActivity = null;
}
}
/** /**
* Returns a {@link TaskInfo} with information from this task. * Returns a {@link TaskInfo} with information from this task.
*/ */