OSDN Git Service

Prevent system uid component from running in an app process
authorWale Ogunwale <ogunwale@google.com>
Thu, 25 Jun 2015 16:29:58 +0000 (09:29 -0700)
committerWale Ogunwale <ogunwale@google.com>
Thu, 25 Jun 2015 16:29:58 +0000 (09:29 -0700)
Bug: 21669445
Change-Id: I792c6e676d4b6d54a51228d264130b8125075d98

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

index c6a97b4..be37b01 100644 (file)
@@ -2526,9 +2526,14 @@ public final class ActivityManagerService extends ActivityManagerNative
             // should never happen).
             SparseArray<ProcessRecord> procs = mProcessNames.getMap().get(processName);
             if (procs == null) return null;
-            final int N = procs.size();
-            for (int i = 0; i < N; i++) {
-                if (UserHandle.isSameUser(procs.keyAt(i), uid)) return procs.valueAt(i);
+            final int procCount = procs.size();
+            for (int i = 0; i < procCount; i++) {
+                final int procUid = procs.keyAt(i);
+                if (UserHandle.isApp(procUid) || !UserHandle.isSameUser(procUid, uid)) {
+                    // Don't use an app process or different user process for system component.
+                    continue;
+                }
+                return procs.valueAt(i);
             }
         }
         ProcessRecord proc = mProcessNames.get(processName, uid);