[RESTRICT AUTOMERGE] Strip part of the activity info of another uid if no privilege
The activity info could be from another uid which is different
from the app that hosts the task. The information should be
trimmed if the caller app doesn't have the privilege.
However, removing the entire info may result in app compatibility
issues. So, only swiping the info that are sensitive to empty
string.
Bug: 243130512
Test: verified market app locally
Test: atest RecentTasksTest
Change-Id: I5b6775dd3c4e2ccdacd30741884d336b2eaa70da
Merged-In: I5b6775dd3c4e2ccdacd30741884d336b2eaa70da
(cherry picked from commit 5ba72200f6)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -961,7 +961,7 @@ class RecentTasks {
|
||||
continue;
|
||||
}
|
||||
|
||||
res.add(createRecentTaskInfo(task, true /* stripExtras */));
|
||||
res.add(createRecentTaskInfo(task, true /* stripExtras */, getTasksAllowed));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -1833,12 +1833,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3631,6 +3631,54 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// Making a copy to prevent eliminating the info in the original ActivityRecord.
|
||||
info.topActivityInfo = new ActivityInfo(info.topActivityInfo);
|
||||
info.topActivityInfo.applicationInfo =
|
||||
new ApplicationInfo(info.topActivityInfo.applicationInfo);
|
||||
|
||||
// Strip the sensitive info.
|
||||
info.topActivity = new ComponentName("", "");
|
||||
info.topActivityInfo.packageName = "";
|
||||
info.topActivityInfo.taskAffinity = "";
|
||||
info.topActivityInfo.processName = "";
|
||||
info.topActivityInfo.name = "";
|
||||
info.topActivityInfo.parentActivityName = "";
|
||||
info.topActivityInfo.targetActivity = "";
|
||||
info.topActivityInfo.splitName = "";
|
||||
info.topActivityInfo.applicationInfo.className = "";
|
||||
info.topActivityInfo.applicationInfo.credentialProtectedDataDir = "";
|
||||
info.topActivityInfo.applicationInfo.dataDir = "";
|
||||
info.topActivityInfo.applicationInfo.deviceProtectedDataDir = "";
|
||||
info.topActivityInfo.applicationInfo.manageSpaceActivityName = "";
|
||||
info.topActivityInfo.applicationInfo.nativeLibraryDir = "";
|
||||
info.topActivityInfo.applicationInfo.nativeLibraryRootDir = "";
|
||||
info.topActivityInfo.applicationInfo.processName = "";
|
||||
info.topActivityInfo.applicationInfo.publicSourceDir = "";
|
||||
info.topActivityInfo.applicationInfo.scanPublicSourceDir = "";
|
||||
info.topActivityInfo.applicationInfo.scanSourceDir = "";
|
||||
info.topActivityInfo.applicationInfo.sourceDir = "";
|
||||
info.topActivityInfo.applicationInfo.taskAffinity = "";
|
||||
info.topActivityInfo.applicationInfo.name = "";
|
||||
info.topActivityInfo.applicationInfo.packageName = "";
|
||||
}
|
||||
|
||||
if (task.effectiveUid != baseActivityUid) {
|
||||
info.baseActivity = new ComponentName("", "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TaskInfo} with information from this task.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user