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

Commit 994e219d authored by Primiano Tucci's avatar Primiano Tucci Committed by Ben Murdoch
Browse files

Cherry pick Move startIsolatedProcess implementation in ActivityManagerService DO NOT MERGE

This CL addresses the comments in CL 512432, moving the implementation
of startIsolatedProcess in the outer ActivityManagerService class and
making the entry point in the ActivityManagerInternal sublcass just
a proxy method.
This change also addresses a potential NPE, due to startProcessLocked
returning null in some failure cases.

Original BUG:16403706
Original Change-Id: I21eff88c23221653f552cfc171647a839e42a802

Bug: 16723226
Change-Id: I4af9fd7eea10b11e06a5c37d8160c220376b3ed1
parent 5651fc2f
Loading
Loading
Loading
Loading
+27 −21
Original line number Diff line number Diff line
@@ -2834,6 +2834,31 @@ public final class ActivityManagerService extends ActivityManagerNative
                || transit == AppTransition.TRANSIT_TASK_TO_FRONT;
    }
    int startIsolatedProcess(String entryPoint, String[] entryPointArgs,
            String processName, String abiOverride, int uid, Runnable crashHandler) {
        synchronized(this) {
            ApplicationInfo info = new ApplicationInfo();
            // In general the ApplicationInfo.uid isn't neccesarily equal to ProcessRecord.uid.
            // For isolated processes, the former contains the parent's uid and the latter the
            // actual uid of the isolated process.
            // In the special case introduced by this method (which is, starting an isolated
            // process directly from the SystemServer without an actual parent app process) the
            // closest thing to a parent's uid is SYSTEM_UID.
            // The only important thing here is to keep AI.uid != PR.uid, in order to trigger
            // the |isolated| logic in the ProcessRecord constructor.
            info.uid = Process.SYSTEM_UID;
            info.processName = processName;
            info.className = entryPoint;
            info.packageName = "android";
            ProcessRecord proc = startProcessLocked(processName, info /* info */,
                    false /* knownToBeDead */, 0 /* intentFlags */, ""  /* hostingType */,
                    null /* hostingName */, true /* allowWhileBooting */, true /* isolated */,
                    uid, true /* keepIfLarge */, abiOverride, entryPoint, entryPointArgs,
                    crashHandler);
            return proc != null ? proc.pid : 0;
        }
    }
    final ProcessRecord startProcessLocked(String processName,
            ApplicationInfo info, boolean knownToBeDead, int intentFlags,
            String hostingType, ComponentName hostingName, boolean allowWhileBooting,
@@ -17887,27 +17912,8 @@ public final class ActivityManagerService extends ActivityManagerNative
        @Override
        public int startIsolatedProcess(String entryPoint, String[] entryPointArgs,
                String processName, String abiOverride, int uid, Runnable crashHandler) {
            synchronized(ActivityManagerService.this) {
                ApplicationInfo info = new ApplicationInfo();
                // In general the ApplicationInfo.uid isn't neccesarily equal to ProcessRecord.uid.
                // For isolated processes, the former contains the parent's uid and the latter the
                // actual uid of the isolated process.
                // In the special case introduced by this method (which is, starting an isolated
                // process directly from the SystemServer without an actual parent app process) the
                // closest thing to a parent's uid is SYSTEM_UID.
                // The only important thing here is to keep AI.uid != PR.uid, in order to trigger
                // the |isolated| logic in the ProcessRecord constructor.
                info.uid = Process.SYSTEM_UID;
                info.processName = processName;
                info.className = entryPoint;
                info.packageName = "android";
                ProcessRecord proc = startProcessLocked(processName, info /* info */,
                        false /* knownToBeDead */, 0 /* intentFlags */, ""  /* hostingType */,
                        null /* hostingName */, true /* allowWhileBooting */, true /* isolated */,
                        uid, true /* keepIfLarge */, abiOverride, entryPoint, entryPointArgs,
                        crashHandler);
                return proc.pid;
            }
            return ActivityManagerService.this.startIsolatedProcess(entryPoint, entryPointArgs,
                    processName, abiOverride, uid, crashHandler);
        }
    }