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

Commit c06f69d2 authored by Anna Trostanetski's avatar Anna Trostanetski Committed by android-build-merger
Browse files

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

am: f33c3a8c

Change-Id: I25e7c5f7375dfa1d6dc5568e7e32810a4e86e82d
parents 05057bd8 f33c3a8c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -519,7 +519,8 @@ public class Process {
     * @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.
     * @return An object that describes the result of the attempt to start the process.
     * @throws RuntimeException on fatal start failure
@@ -538,11 +539,12 @@ public class Process {
                                           @Nullable String appDataDir,
                                           @Nullable String invokeWith,
                                           @Nullable String packageName,
                                           @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, zygoteArgs);
                    /*useUsapPool=*/ true, disabledCompatChanges, zygoteArgs);
    }

    /** @hide */
@@ -558,11 +560,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, zygoteArgs);
                    /*useUsapPool=*/ false, disabledCompatChanges, zygoteArgs);
    }

    /**
+23 −2
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.
     *
     * @return An object that describes the result of the attempt to start the process.
@@ -323,6 +325,7 @@ public class ZygoteProcess {
                                                  @Nullable String invokeWith,
                                                  @Nullable String packageName,
                                                  boolean useUsapPool,
                                                  @Nullable long[] disabledCompatChanges,
                                                  @Nullable String[] zygoteArgs) {
        // TODO (chriswailes): Is there a better place to check this value?
        if (fetchUsapPoolEnabledPropWithMinInterval()) {
@@ -333,7 +336,7 @@ public class ZygoteProcess {
            return startViaZygote(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false,
                    packageName, useUsapPool, zygoteArgs);
                    packageName, useUsapPool, disabledCompatChanges, zygoteArgs);
        } catch (ZygoteStartFailedEx ex) {
            Log.e(LOG_TAG,
                    "Starting VM process through Zygote failed");
@@ -534,6 +537,7 @@ public class ZygoteProcess {
     * @param startChildZygote Start a sub-zygote. This creates a new zygote process
     * that has its state cloned from this zygote process.
     * @param packageName null-ok the name of the package this process belongs to.
     * @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
@@ -552,6 +556,7 @@ public class ZygoteProcess {
                                                      boolean startChildZygote,
                                                      @Nullable String packageName,
                                                      boolean useUsapPool,
                                                      @Nullable long[] disabledCompatChanges,
                                                      @Nullable String[] extraArgs)
                                                      throws ZygoteStartFailedEx {
        ArrayList<String> argsForZygote = new ArrayList<>();
@@ -623,6 +628,21 @@ public class ZygoteProcess {
            argsForZygote.add("--package-name=" + packageName);
        }

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

            final 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) {
@@ -1170,7 +1190,8 @@ public class ZygoteProcess {
                    gids, runtimeFlags, 0 /* mountExternal */, 0 /* targetSdkVersion */, seInfo,
                    abi, instructionSet, null /* appDataDir */, null /* invokeWith */,
                    true /* startChildZygote */, null /* packageName */,
                    false /* useUsapPool */, extraArgs);
                    false /* useUsapPool */,
                    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
@@ -642,6 +642,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