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

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

Merge "Add javadoc for package-name arg passed during the process start."

parents d3132319 d81b1d76
Loading
Loading
Loading
Loading
+23 −20
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.os;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.system.Os;
import android.system.OsConstants;
@@ -475,6 +477,7 @@ public class Process {
     * @param instructionSet null-ok the instruction set to use.
     * @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 zygoteArgs Additional arguments to supply to the zygote process.
     * 
     * @return An object that describes the result of the attempt to start the process.
@@ -482,36 +485,36 @@ public class Process {
     * 
     * {@hide}
     */
    public static final ProcessStartResult start(final String processClass,
                                  final String niceName,
                                  int uid, int gid, int[] gids,
    public static final ProcessStartResult start(@NonNull final String processClass,
                                  @Nullable final String niceName,
                                  int uid, int gid, @Nullable int[] gids,
                                  int runtimeFlags, int mountExternal,
                                  int targetSdkVersion,
                                  String seInfo,
                                  String abi,
                                  String instructionSet,
                                  String appDataDir,
                                  String invokeWith,
                                  String packageName,
                                  String[] zygoteArgs) {
                                  @Nullable String seInfo,
                                  @NonNull String abi,
                                  @Nullable String instructionSet,
                                  @Nullable String appDataDir,
                                  @Nullable String invokeWith,
                                  @Nullable String packageName,
                                  @Nullable String[] zygoteArgs) {
        return zygoteProcess.start(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, packageName, zygoteArgs);
    }

    /** @hide */
    public static final ProcessStartResult startWebView(final String processClass,
                                  final String niceName,
                                  int uid, int gid, int[] gids,
    public static final ProcessStartResult startWebView(@NonNull final String processClass,
                                  @Nullable final String niceName,
                                  int uid, int gid, @Nullable int[] gids,
                                  int runtimeFlags, int mountExternal,
                                  int targetSdkVersion,
                                  String seInfo,
                                  String abi,
                                  String instructionSet,
                                  String appDataDir,
                                  String invokeWith,
                                  String packageName,
                                  String[] zygoteArgs) {
                                  @Nullable String seInfo,
                                  @NonNull String abi,
                                  @Nullable String instructionSet,
                                  @Nullable String appDataDir,
                                  @Nullable String invokeWith,
                                  @Nullable String packageName,
                                  @Nullable String[] zygoteArgs) {
        return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
                    abi, instructionSet, appDataDir, invokeWith, packageName, zygoteArgs);
+23 −19
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.os;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.util.Log;
@@ -212,23 +214,24 @@ public class ZygoteProcess {
     * @param instructionSet null-ok the instruction set to use.
     * @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 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
     */
    public final Process.ProcessStartResult start(final String processClass,
    public final Process.ProcessStartResult start(@NonNull final String processClass,
                                                  final String niceName,
                                                  int uid, int gid, int[] gids,
                                                  int uid, int gid, @Nullable int[] gids,
                                                  int runtimeFlags, int mountExternal,
                                                  int targetSdkVersion,
                                                  String seInfo,
                                                  String abi,
                                                  String instructionSet,
                                                  String appDataDir,
                                                  String invokeWith,
                                                  String packageName,
                                                  String[] zygoteArgs) {
                                                  @Nullable String seInfo,
                                                  @NonNull String abi,
                                                  @Nullable String instructionSet,
                                                  @Nullable String appDataDir,
                                                  @Nullable String invokeWith,
                                                  @Nullable String packageName,
                                                  @Nullable String[] zygoteArgs) {
        try {
            return startViaZygote(processClass, niceName, uid, gid, gids,
                    runtimeFlags, mountExternal, targetSdkVersion, seInfo,
@@ -351,24 +354,25 @@ public class ZygoteProcess {
     * @param appDataDir null-ok the data directory of the app.
     * @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 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
     */
    private Process.ProcessStartResult startViaZygote(final String processClass,
                                                      final String niceName,
    private Process.ProcessStartResult startViaZygote(@NonNull final String processClass,
                                                      @Nullable final String niceName,
                                                      final int uid, final int gid,
                                                      final int[] gids,
                                                      @Nullable final int[] gids,
                                                      int runtimeFlags, int mountExternal,
                                                      int targetSdkVersion,
                                                      String seInfo,
                                                      String abi,
                                                      String instructionSet,
                                                      String appDataDir,
                                                      String invokeWith,
                                                      @Nullable String seInfo,
                                                      @NonNull String abi,
                                                      @Nullable String instructionSet,
                                                      @Nullable String appDataDir,
                                                      @Nullable String invokeWith,
                                                      boolean startChildZygote,
                                                      String packageName,
                                                      String[] extraArgs)
                                                      @Nullable String packageName,
                                                      @Nullable String[] extraArgs)
                                                      throws ZygoteStartFailedEx {
        ArrayList<String> argsForZygote = new ArrayList<String>();

+9 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.system.OsConstants.POLLIN;
import static android.system.OsConstants.STDERR_FILENO;
import static android.system.OsConstants.STDIN_FILENO;
import static android.system.OsConstants.STDOUT_FILENO;

import static com.android.internal.os.ZygoteConnectionConstants.CONNECTION_TIMEOUT_MILLIS;
import static com.android.internal.os.ZygoteConnectionConstants.MAX_ZYGOTE_ARGC;
import static com.android.internal.os.ZygoteConnectionConstants.WRAPPED_PID_TIMEOUT_MILLIS;
@@ -36,12 +37,15 @@ import android.system.ErrnoException;
import android.system.Os;
import android.system.StructPollfd;
import android.util.Log;

import dalvik.system.VMRuntime;

import libcore.io.IoUtils;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -49,8 +53,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;

import libcore.io.IoUtils;

/**
 * A connection that can make spawn requests.
 */
@@ -377,6 +379,7 @@ class ZygoteConnection {
     *    are the settings for current and max value.</i>
     *   <li> --instruction-set=<i>instruction-set-string</i> which instruction set to use/emulate.
     *   <li> --nice-name=<i>nice name to appear in ps</i>
     *   <li> --package-name=<i>package name this process belongs to</i>
     *   <li> --runtime-args indicates that the remaining arg list should
     * be handed off to com.android.internal.os.RuntimeInit, rather than
     * processed directly.
@@ -680,6 +683,9 @@ class ZygoteConnection {
                    }
                    expectRuntimeArgs = false;
                } else if (arg.startsWith("--package-name=")) {
                    if (packageName != null) {
                        throw new IllegalArgumentException("Duplicate arg specified");
                    }
                    packageName = arg.substring(arg.indexOf('=') + 1);
                } else {
                    break;