Skip to content

Commit b481410

Browse files
ogunwaleThe Android Automerger
authored andcommitted
Lockdown AM.getRunningAppProcesses API with permission.REAL_GET_TASKS
* Applications must now have ...permission.REAL_GET_TASKS to be able to get process information for all applications. * Only the process information for the calling application will be returned if the app doesn't have the permission. * Privilages apps will temporarily be able to get process information for all applications if they don't have the new permission, but have deprecated ...permission.GET_TASKS. Bug: 20034603 Change-Id: I67ae9491f65d2280adb6a81593693d499714a216 (cherry picked from commit 9dbaa54)
1 parent b7a79bd commit b481410

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

services/core/java/com/android/server/am/ActivityManagerService.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8122,7 +8122,7 @@ private boolean isGetTasksAllowed(String caller, int callingPid, int callingUid)
81228122
}
81238123
if (!allowed) {
81248124
Slog.w(TAG, caller + ": caller " + callingUid
8125-
+ " does not hold GET_TASKS; limiting output");
8125+
+ " does not hold REAL_GET_TASKS; limiting output");
81268126
}
81278127
return allowed;
81288128
}
@@ -12241,16 +12241,23 @@ private void fillInProcMemInfo(ProcessRecord app,
1224112241

1224212242
public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() {
1224312243
enforceNotIsolatedCaller("getRunningAppProcesses");
12244+
12245+
final int callingUid = Binder.getCallingUid();
12246+
1224412247
// Lazy instantiation of list
1224512248
List<ActivityManager.RunningAppProcessInfo> runList = null;
1224612249
final boolean allUsers = ActivityManager.checkUidPermission(INTERACT_ACROSS_USERS_FULL,
12247-
Binder.getCallingUid()) == PackageManager.PERMISSION_GRANTED;
12248-
int userId = UserHandle.getUserId(Binder.getCallingUid());
12250+
callingUid) == PackageManager.PERMISSION_GRANTED;
12251+
final int userId = UserHandle.getUserId(callingUid);
12252+
final boolean allUids = isGetTasksAllowed(
12253+
"getRunningAppProcesses", Binder.getCallingPid(), callingUid);
12254+
1224912255
synchronized (this) {
1225012256
// Iterate across all processes
12251-
for (int i=mLruProcesses.size()-1; i>=0; i--) {
12257+
for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
1225212258
ProcessRecord app = mLruProcesses.get(i);
12253-
if (!allUsers && app.userId != userId) {
12259+
if ((!allUsers && app.userId != userId)
12260+
|| (!allUids && app.uid != callingUid)) {
1225412261
continue;
1225512262
}
1225612263
if ((app.thread != null) && (!app.crashing && !app.notResponding)) {
@@ -12274,7 +12281,7 @@ public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() {
1227412281
//Slog.v(TAG, "Proc " + app.processName + ": imp=" + currApp.importance
1227512282
// + " lru=" + currApp.lru);
1227612283
if (runList == null) {
12277-
runList = new ArrayList<ActivityManager.RunningAppProcessInfo>();
12284+
runList = new ArrayList<>();
1227812285
}
1227912286
runList.add(currApp);
1228012287
}

0 commit comments

Comments
 (0)