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

Commit 0f15f727 authored by Anna Trostanetski's avatar Anna Trostanetski Committed by Android (Google) Code Review
Browse files

Merge "Pipe disabled compat changes to runtime through zygote."

parents ab43bef7 5ae996f8
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -519,7 +519,8 @@ public class Process {
     * @param invokeWith null-ok the command to invoke with.
     * @param packageName null-ok the name of the package this process belongs to.
     * @param isTopApp whether the process starts for high priority application.
     *
     * @param disabledCompatChanges null-ok list of disabled compat changes for the process being
     *                             started.
     * @param zygoteArgs Additional arguments to supply to the zygote process.
     * @return An object that describes the result of the attempt to start the process.
     * @throws RuntimeException on fatal start failure
@@ -539,11 +540,12 @@ public class Process {
                                           @Nullable String invokeWith,
                                           @Nullable String packageName,
                                           boolean isTopApp,
                                           @Nullable long[] disabledCompatChanges,
                                           @Nullable String[] zygoteArgs) {
        return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, packageName,
                    /*useUsapPool=*/ true, isTopApp, zygoteArgs);
                    /*useUsapPool=*/ true, isTopApp, disabledCompatChanges, zygoteArgs);
    }

    /** @hide */
@@ -559,11 +561,12 @@ public class Process {
                                                  @Nullable String appDataDir,
                                                  @Nullable String invokeWith,
                                                  @Nullable String packageName,
                                                  @Nullable long[] disabledCompatChanges,
                                                  @Nullable String[] zygoteArgs) {
        return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, packageName,
                    /*useUsapPool=*/ false, /*isTopApp=*/ false, zygoteArgs);
                    /*useUsapPool=*/ false, /*isTopApp=*/ false, disabledCompatChanges, zygoteArgs);
    }

    /**
+25 −4
Original line number Diff line number Diff line
@@ -306,6 +306,8 @@ public class ZygoteProcess {
     * @param appDataDir null-ok the data directory of the app.
     * @param invokeWith null-ok the command to invoke with.
     * @param packageName null-ok the name of the package this process belongs to.
     * @param disabledCompatChanges null-ok list of disabled compat changes for the process being
     *                             started.
     * @param zygoteArgs Additional arguments to supply to the zygote process.
     * @param isTopApp Whether the process starts for high priority application.
     *
@@ -325,6 +327,7 @@ public class ZygoteProcess {
                                                  @Nullable String packageName,
                                                  boolean useUsapPool,
                                                  boolean isTopApp,
                                                  @Nullable long[] disabledCompatChanges,
                                                  @Nullable String[] zygoteArgs) {
        // TODO (chriswailes): Is there a better place to check this value?
        if (fetchUsapPoolEnabledPropWithMinInterval()) {
@@ -335,7 +338,7 @@ public class ZygoteProcess {
            return startViaZygote(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false,
                    packageName, useUsapPool, isTopApp, zygoteArgs);
                    packageName, useUsapPool, isTopApp, disabledCompatChanges, zygoteArgs);
        } catch (ZygoteStartFailedEx ex) {
            Log.e(LOG_TAG,
                    "Starting VM process through Zygote failed");
@@ -535,6 +538,7 @@ public class ZygoteProcess {
     * that has its state cloned from this zygote process.
     * @param packageName null-ok the name of the package this process belongs to.
     * @param isTopApp Whether the process starts for high priority application.
     * @param disabledCompatChanges a list of disabled compat changes for the process being started.
     * @param extraArgs Additional arguments to supply to the zygote process.
     * @return An object that describes the result of the attempt to start the process.
     * @throws ZygoteStartFailedEx if process start failed for any reason
@@ -554,6 +558,7 @@ public class ZygoteProcess {
                                                      @Nullable String packageName,
                                                      boolean useUsapPool,
                                                      boolean isTopApp,
                                                      @Nullable long[] disabledCompatChanges,
                                                      @Nullable String[] extraArgs)
                                                      throws ZygoteStartFailedEx {
        ArrayList<String> argsForZygote = new ArrayList<>();
@@ -584,10 +589,10 @@ public class ZygoteProcess {

        // --setgroups is a comma-separated list
        if (gids != null && gids.length > 0) {
            StringBuilder sb = new StringBuilder();
            final StringBuilder sb = new StringBuilder();
            sb.append("--setgroups=");

            int sz = gids.length;
            final int sz = gids.length;
            for (int i = 0; i < sz; i++) {
                if (i != 0) {
                    sb.append(',');
@@ -631,6 +636,21 @@ public class ZygoteProcess {
            argsForZygote.add(Zygote.START_AS_TOP_APP_ARG);
        }

        if (disabledCompatChanges != null && disabledCompatChanges.length > 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("--disabled-compat-changes=");

            int sz = disabledCompatChanges.length;
            for (int i = 0; i < sz; i++) {
                if (i != 0) {
                    sb.append(',');
                }
                sb.append(disabledCompatChanges[i]);
            }

            argsForZygote.add(sb.toString());
        }

        argsForZygote.add(processClass);

        if (extraArgs != null) {
@@ -1166,7 +1186,8 @@ public class ZygoteProcess {
                    gids, runtimeFlags, 0 /* mountExternal */, 0 /* targetSdkVersion */, seInfo,
                    abi, instructionSet, null /* appDataDir */, null /* invokeWith */,
                    true /* startChildZygote */, null /* packageName */,
                    false /* useUsapPool */, false /* isTopApp */, extraArgs);
                    false /* useUsapPool */, false /* isTopApp */,
                    null /* disabledCompatChanges */, extraArgs);
        } catch (ZygoteStartFailedEx ex) {
            throw new RuntimeException("Starting child-zygote through Zygote failed", ex);
        }
+3 −2
Original line number Diff line number Diff line
@@ -367,8 +367,8 @@ public class RuntimeInit {
        if (DEBUG) Slog.d(TAG, "Leaving RuntimeInit!");
    }

    protected static Runnable applicationInit(int targetSdkVersion, String[] argv,
            ClassLoader classLoader) {
    protected static Runnable applicationInit(int targetSdkVersion, long[] disabledCompatChanges,
            String[] argv, ClassLoader classLoader) {
        // If the application calls System.exit(), terminate the process
        // immediately without running any shutdown hooks.  It is not possible to
        // shutdown an Android application gracefully.  Among other things, the
@@ -377,6 +377,7 @@ public class RuntimeInit {
        nativeSetExitWithoutCleanup(true);

        VMRuntime.getRuntime().setTargetSdkVersion(targetSdkVersion);
        VMRuntime.getRuntime().setDisabledCompatChanges(disabledCompatChanges);

        final Arguments args = new Arguments(argv);

+7 −5
Original line number Diff line number Diff line
@@ -23,16 +23,18 @@ import android.system.Os;
import android.system.OsConstants;
import android.system.StructCapUserData;
import android.system.StructCapUserHeader;
import android.util.TimingsTraceLog;
import android.util.Slog;
import android.util.TimingsTraceLog;

import dalvik.system.VMRuntime;

import libcore.io.IoUtils;

import java.io.DataOutputStream;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;

import libcore.io.IoUtils;

/**
 * Startup class for the wrapper process.
 * @hide
@@ -166,10 +168,10 @@ public class WrapperInit {
            System.arraycopy(argv, 2, removedArgs, 0, argv.length - 2);
            argv = removedArgs;
        }

        // Perform the same initialization that would happen after the Zygote forks.
        Zygote.nativePreApplicationInit();
        return RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader);
        return RuntimeInit.applicationInit(targetSdkVersion, /*disabledCompatChanges*/ null,
                argv, classLoader);
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -672,6 +672,7 @@ public final class Zygote {
            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

            return ZygoteInit.zygoteInit(args.mTargetSdkVersion,
                                         args.mDisabledCompatChanges,
                                         args.mRemainingArgs,
                                         null /* classLoader */);
        } finally {
Loading