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

Commit b430d8ff authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Start processes asynchronously in AMS."

parents 77dadd93 f6690100
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -99,7 +99,10 @@ public abstract class ActivityManagerInternal {
    // Called by the power manager.
    public abstract void onWakefulnessChanged(int wakefulness);

    public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
    /**
     * @return {@code true} if process start is successful, {@code false} otherwise.
     */
    public abstract boolean startIsolatedProcess(String entryPoint, String[] mainArgs,
            String processName, String abiOverride, int uid, Runnable crashHandler);

    /**
+21 −4
Original line number Diff line number Diff line
@@ -225,6 +225,12 @@ public final class ActivityThread extends ClientTransactionHandler {
     */
    public static final long INVALID_PROC_STATE_SEQ = -1;

    /**
     * Identifier for the sequence no. associated with this process start. It will be provided
     * as one of the arguments when the process starts.
     */
    public static final String PROC_START_SEQ_IDENT = "seq=";

    private final Object mNetworkPolicyLock = new Object();

    /**
@@ -6289,7 +6295,7 @@ public final class ActivityThread extends ClientTransactionHandler {
        System.exit(0);
    }

    private void attach(boolean system) {
    private void attach(boolean system, long startSeq) {
        sCurrentActivityThread = this;
        mSystemThread = system;
        if (!system) {
@@ -6304,7 +6310,7 @@ public final class ActivityThread extends ClientTransactionHandler {
            RuntimeInit.setApplicationObject(mAppThread.asBinder());
            final IActivityManager mgr = ActivityManager.getService();
            try {
                mgr.attachApplication(mAppThread);
                mgr.attachApplication(mAppThread, startSeq);
            } catch (RemoteException ex) {
                throw ex.rethrowFromSystemServer();
            }
@@ -6383,7 +6389,7 @@ public final class ActivityThread extends ClientTransactionHandler {
            ThreadedRenderer.enableForegroundTrimming();
        }
        ActivityThread thread = new ActivityThread();
        thread.attach(true);
        thread.attach(true, 0);
        return thread;
    }

@@ -6455,8 +6461,19 @@ public final class ActivityThread extends ClientTransactionHandler {

        Looper.prepareMainLooper();

        // Find the value for {@link #PROC_START_SEQ_IDENT} if provided on the command line.
        // It will be in the format "seq=114"
        long startSeq = 0;
        if (args != null) {
            for (int i = args.length - 1; i >= 0; --i) {
                if (args[i] != null && args[i].startsWith(PROC_START_SEQ_IDENT)) {
                    startSeq = Long.parseLong(
                            args[i].substring(PROC_START_SEQ_IDENT.length()));
                }
            }
        }
        ActivityThread thread = new ActivityThread();
        thread.attach(false);
        thread.attach(false, startSeq);

        if (sMainThreadHandler == null) {
            sMainThreadHandler = thread.getHandler();
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ interface IActivityManager {
    void unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId);
    oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
            boolean abortBroadcast, int flags);
    void attachApplication(in IApplicationThread app);
    void attachApplication(in IApplicationThread app, long startSeq);
    oneway void activityIdle(in IBinder token, in Configuration config,
            in boolean stopProfiling);
    void activityPaused(in IBinder token);
+1 −0
Original line number Diff line number Diff line
@@ -9466,6 +9466,7 @@ public final class Settings {
         * service_min_restart_time_between     (long)
         * service_max_inactivity               (long)
         * service_bg_start_timeout             (long)
         * process_start_async                  (boolean)
         * </pre>
         *
         * <p>
+5 −4
Original line number Diff line number Diff line
@@ -123,10 +123,11 @@ public class WebViewLibraryLoader {
                throw new IllegalArgumentException(
                        "Native library paths to the WebView RelRo process must not be null!");
            }
            int pid = LocalServices.getService(ActivityManagerInternal.class).startIsolatedProcess(
            boolean success = LocalServices.getService(ActivityManagerInternal.class)
                    .startIsolatedProcess(
                            RelroFileCreator.class.getName(), new String[] { nativeLib.path },
                            "WebViewLoader-" + abi, abi, Process.SHARED_RELRO_UID, crashHandler);
            if (pid <= 0) throw new Exception("Failed to start the relro file creator process");
            if (!success) throw new Exception("Failed to start the relro file creator process");
        } catch (Throwable t) {
            // Log and discard errors as we must not crash the system server.
            Log.e(LOGTAG, "error starting relro file creator for abi " + abi, t);
Loading