Merge "Code cleanup to conform to style guide / linter."

am: f5ff8f0661

Change-Id: If6c04c711b328c114d04ea8b4aa01414a715b7a2
This commit is contained in:
Christian Wailes
2019-01-23 17:42:24 -08:00
committed by android-build-merger
7 changed files with 169 additions and 138 deletions

View File

@@ -29,16 +29,6 @@ import dalvik.system.VMRuntime;
public class Process { public class Process {
private static final String LOG_TAG = "Process"; private static final String LOG_TAG = "Process";
/**
* @hide for internal use only.
*/
public static final String ZYGOTE_SOCKET = "zygote";
/**
* @hide for internal use only.
*/
public static final String SECONDARY_ZYGOTE_SOCKET = "zygote_secondary";
/** /**
* An invalid UID value. * An invalid UID value.
*/ */
@@ -454,8 +444,7 @@ public class Process {
* State associated with the zygote process. * State associated with the zygote process.
* @hide * @hide
*/ */
public static final ZygoteProcess zygoteProcess = public static final ZygoteProcess ZYGOTE_PROCESS = new ZygoteProcess();
new ZygoteProcess(ZYGOTE_SOCKET, SECONDARY_ZYGOTE_SOCKET);
/** /**
* Start a new process. * Start a new process.
@@ -507,7 +496,7 @@ public class Process {
String appDataDir, String appDataDir,
String invokeWith, String invokeWith,
String[] zygoteArgs) { String[] zygoteArgs) {
return zygoteProcess.start(processClass, niceName, uid, gid, gids, return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo, runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, zygoteArgs); abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
} }

View File

@@ -58,87 +58,119 @@ import java.util.UUID;
* {@hide} * {@hide}
*/ */
public class ZygoteProcess { public class ZygoteProcess {
/**
* @hide for internal use only.
*/
public static final String ZYGOTE_SOCKET_NAME = "zygote";
/**
* @hide for internal use only.
*/
public static final String ZYGOTE_SECONDARY_SOCKET_NAME = "zygote_secondary";
/**
* @hide for internal use only
*/
private static final String LOG_TAG = "ZygoteProcess"; private static final String LOG_TAG = "ZygoteProcess";
/** /**
* The name of the socket used to communicate with the primary zygote. * The name of the socket used to communicate with the primary zygote.
*/ */
private final LocalSocketAddress mSocket; private final LocalSocketAddress mZygoteSocketAddress;
/** /**
* The name of the secondary (alternate ABI) zygote socket. * The name of the secondary (alternate ABI) zygote socket.
*/ */
private final LocalSocketAddress mSecondarySocket; private final LocalSocketAddress mZygoteSecondarySocketAddress;
public ZygoteProcess(String primarySocket, String secondarySocket) { public ZygoteProcess() {
this(new LocalSocketAddress(primarySocket, LocalSocketAddress.Namespace.RESERVED), mZygoteSocketAddress =
new LocalSocketAddress(secondarySocket, LocalSocketAddress.Namespace.RESERVED)); new LocalSocketAddress(ZYGOTE_SOCKET_NAME, LocalSocketAddress.Namespace.RESERVED);
mZygoteSecondarySocketAddress =
new LocalSocketAddress(ZYGOTE_SECONDARY_SOCKET_NAME,
LocalSocketAddress.Namespace.RESERVED);
} }
public ZygoteProcess(LocalSocketAddress primarySocket, LocalSocketAddress secondarySocket) { public ZygoteProcess(LocalSocketAddress primarySocketAddress,
mSocket = primarySocket; LocalSocketAddress secondarySocketAddress) {
mSecondarySocket = secondarySocket; mZygoteSocketAddress = primarySocketAddress;
mZygoteSecondarySocketAddress = secondarySocketAddress;
} }
public LocalSocketAddress getPrimarySocketAddress() { public LocalSocketAddress getPrimarySocketAddress() {
return mSocket; return mZygoteSocketAddress;
} }
/** /**
* State for communicating with the zygote process. * State for communicating with the zygote process.
*/ */
public static class ZygoteState { public static class ZygoteState {
final LocalSocket socket; final LocalSocketAddress mZygoteSocketAddress;
final DataInputStream inputStream;
final BufferedWriter writer;
final List<String> abiList;
boolean mClosed; private final LocalSocket mZygoteSessionSocket;
private ZygoteState(LocalSocket socket, DataInputStream inputStream, final DataInputStream mZygoteInputStream;
BufferedWriter writer, List<String> abiList) { final BufferedWriter mZygoteOutputWriter;
this.socket = socket;
this.inputStream = inputStream; private final List<String> mABIList;
this.writer = writer;
this.abiList = abiList; private boolean mClosed;
private ZygoteState(LocalSocketAddress zygoteSocketAddress,
LocalSocket zygoteSessionSocket,
DataInputStream zygoteInputStream,
BufferedWriter zygoteOutputWriter,
List<String> abiList) {
this.mZygoteSocketAddress = zygoteSocketAddress;
this.mZygoteSessionSocket = zygoteSessionSocket;
this.mZygoteInputStream = zygoteInputStream;
this.mZygoteOutputWriter = zygoteOutputWriter;
this.mABIList = abiList;
} }
public static ZygoteState connect(LocalSocketAddress address) throws IOException { /**
* Create a new ZygoteState object by connecting to the given Zygote socket.
*
* @param zygoteSocketAddress Zygote socket to connect to
* @return A new ZygoteState object containing a session socket for the given Zygote socket
* address
* @throws IOException
*/
public static ZygoteState connect(LocalSocketAddress zygoteSocketAddress)
throws IOException {
DataInputStream zygoteInputStream = null; DataInputStream zygoteInputStream = null;
BufferedWriter zygoteWriter = null; BufferedWriter zygoteOutputWriter = null;
final LocalSocket zygoteSocket = new LocalSocket(); final LocalSocket zygoteSessionSocket = new LocalSocket();
try { try {
zygoteSocket.connect(address); zygoteSessionSocket.connect(zygoteSocketAddress);
zygoteInputStream = new DataInputStream(zygoteSessionSocket.getInputStream());
zygoteInputStream = new DataInputStream(zygoteSocket.getInputStream()); zygoteOutputWriter =
new BufferedWriter(
zygoteWriter = new BufferedWriter(new OutputStreamWriter( new OutputStreamWriter(zygoteSessionSocket.getOutputStream()),
zygoteSocket.getOutputStream()), 256); 256);
} catch (IOException ex) { } catch (IOException ex) {
try { try {
zygoteSocket.close(); zygoteSessionSocket.close();
} catch (IOException ignore) { } catch (IOException ignore) { }
}
throw ex; throw ex;
} }
String abiListString = getAbiList(zygoteWriter, zygoteInputStream); return new ZygoteState(zygoteSocketAddress,
Log.i("Zygote", "Process: zygote socket " + address.getNamespace() + "/" zygoteSessionSocket, zygoteInputStream, zygoteOutputWriter,
+ address.getName() + " opened, supported ABIS: " + abiListString); getAbiList(zygoteOutputWriter, zygoteInputStream));
return new ZygoteState(zygoteSocket, zygoteInputStream, zygoteWriter,
Arrays.asList(abiListString.split(",")));
} }
boolean matches(String abi) { boolean matches(String abi) {
return abiList.contains(abi); return mABIList.contains(abi);
} }
public void close() { public void close() {
try { try {
socket.close(); mZygoteSessionSocket.close();
} catch (IOException ex) { } catch (IOException ex) {
Log.e(LOG_TAG,"I/O exception on routine close", ex); Log.e(LOG_TAG,"I/O exception on routine close", ex);
} }
@@ -231,8 +263,8 @@ public class ZygoteProcess {
try { try {
return startViaZygote(processClass, niceName, uid, gid, gids, return startViaZygote(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo, runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, false /* startChildZygote */, abi, instructionSet, appDataDir, invokeWith,
zygoteArgs); /*startChildZygote=*/false, zygoteArgs);
} catch (ZygoteStartFailedEx ex) { } catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG, Log.e(LOG_TAG,
"Starting VM process through Zygote failed"); "Starting VM process through Zygote failed");
@@ -250,7 +282,7 @@ public class ZygoteProcess {
* @throws ZygoteStartFailedEx if the query failed. * @throws ZygoteStartFailedEx if the query failed.
*/ */
@GuardedBy("mLock") @GuardedBy("mLock")
private static String getAbiList(BufferedWriter writer, DataInputStream inputStream) private static List<String> getAbiList(BufferedWriter writer, DataInputStream inputStream)
throws IOException { throws IOException {
// Each query starts with the argument count (1 in this case) // Each query starts with the argument count (1 in this case)
writer.write("1"); writer.write("1");
@@ -266,7 +298,9 @@ public class ZygoteProcess {
byte[] bytes = new byte[numBytes]; byte[] bytes = new byte[numBytes];
inputStream.readFully(bytes); inputStream.readFully(bytes);
return new String(bytes, StandardCharsets.US_ASCII); String rawList = new String(bytes, StandardCharsets.US_ASCII);
return Arrays.asList(rawList.split(","));
} }
/** /**
@@ -300,8 +334,8 @@ public class ZygoteProcess {
* the child or -1 on failure, followed by boolean to * the child or -1 on failure, followed by boolean to
* indicate whether a wrapper process was used. * indicate whether a wrapper process was used.
*/ */
final BufferedWriter writer = zygoteState.writer; final BufferedWriter writer = zygoteState.mZygoteOutputWriter;
final DataInputStream inputStream = zygoteState.inputStream; final DataInputStream inputStream = zygoteState.mZygoteInputStream;
writer.write(Integer.toString(args.size())); writer.write(Integer.toString(args.size()));
writer.newLine(); writer.newLine();
@@ -475,18 +509,18 @@ public class ZygoteProcess {
ZygoteState state = openZygoteSocketIfNeeded(abi); ZygoteState state = openZygoteSocketIfNeeded(abi);
// Each query starts with the argument count (1 in this case) // Each query starts with the argument count (1 in this case)
state.writer.write("1"); state.mZygoteOutputWriter.write("1");
// ... followed by a new-line. // ... followed by a new-line.
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
// ... followed by our only argument. // ... followed by our only argument.
state.writer.write("--get-pid"); state.mZygoteOutputWriter.write("--get-pid");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.flush(); state.mZygoteOutputWriter.flush();
// The response is a length prefixed stream of ASCII bytes. // The response is a length prefixed stream of ASCII bytes.
int numBytes = state.inputStream.readInt(); int numBytes = state.mZygoteInputStream.readInt();
byte[] bytes = new byte[numBytes]; byte[] bytes = new byte[numBytes];
state.inputStream.readFully(bytes); state.mZygoteInputStream.readFully(bytes);
return Integer.parseInt(new String(bytes, StandardCharsets.US_ASCII)); return Integer.parseInt(new String(bytes, StandardCharsets.US_ASCII));
} }
@@ -540,16 +574,16 @@ public class ZygoteProcess {
return true; return true;
} }
try { try {
state.writer.write(Integer.toString(mApiBlacklistExemptions.size() + 1)); state.mZygoteOutputWriter.write(Integer.toString(mApiBlacklistExemptions.size() + 1));
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write("--set-api-blacklist-exemptions"); state.mZygoteOutputWriter.write("--set-api-blacklist-exemptions");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
for (int i = 0; i < mApiBlacklistExemptions.size(); ++i) { for (int i = 0; i < mApiBlacklistExemptions.size(); ++i) {
state.writer.write(mApiBlacklistExemptions.get(i)); state.mZygoteOutputWriter.write(mApiBlacklistExemptions.get(i));
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
} }
state.writer.flush(); state.mZygoteOutputWriter.flush();
int status = state.inputStream.readInt(); int status = state.mZygoteInputStream.readInt();
if (status != 0) { if (status != 0) {
Slog.e(LOG_TAG, "Failed to set API blacklist exemptions; status " + status); Slog.e(LOG_TAG, "Failed to set API blacklist exemptions; status " + status);
} }
@@ -569,13 +603,13 @@ public class ZygoteProcess {
return; return;
} }
try { try {
state.writer.write(Integer.toString(1)); state.mZygoteOutputWriter.write(Integer.toString(1));
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write("--hidden-api-log-sampling-rate=" state.mZygoteOutputWriter.write("--hidden-api-log-sampling-rate="
+ Integer.toString(mHiddenApiAccessLogSampleRate)); + Integer.toString(mHiddenApiAccessLogSampleRate));
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.flush(); state.mZygoteOutputWriter.flush();
int status = state.inputStream.readInt(); int status = state.mZygoteInputStream.readInt();
if (status != 0) { if (status != 0) {
Slog.e(LOG_TAG, "Failed to set hidden API log sampling rate; status " + status); Slog.e(LOG_TAG, "Failed to set hidden API log sampling rate; status " + status);
} }
@@ -585,22 +619,29 @@ public class ZygoteProcess {
} }
/** /**
* Tries to open socket to Zygote process if not already open. If * Tries to open a session socket to a Zygote process with a compatible ABI if one is not
* already open, does nothing. May block and retry. Requires that mLock be held. * already open. If a compatible session socket is already open that session socket is returned.
* This function may block and may have to try connecting to multiple Zygotes to find the
* appropriate one. Requires that mLock be held.
*/ */
@GuardedBy("mLock") @GuardedBy("mLock")
private ZygoteState openZygoteSocketIfNeeded(String abi) throws ZygoteStartFailedEx { private ZygoteState openZygoteSocketIfNeeded(String abi)
throws ZygoteStartFailedEx {
Preconditions.checkState(Thread.holdsLock(mLock), "ZygoteProcess lock not held"); Preconditions.checkState(Thread.holdsLock(mLock), "ZygoteProcess lock not held");
if (primaryZygoteState == null || primaryZygoteState.isClosed()) { if (primaryZygoteState == null || primaryZygoteState.isClosed()) {
try { try {
primaryZygoteState = ZygoteState.connect(mSocket); primaryZygoteState =
ZygoteState.connect(mZygoteSocketAddress);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new ZygoteStartFailedEx("Error connecting to primary zygote", ioe); throw new ZygoteStartFailedEx("Error connecting to primary zygote", ioe);
} }
maybeSetApiBlacklistExemptions(primaryZygoteState, false); maybeSetApiBlacklistExemptions(primaryZygoteState, false);
maybeSetHiddenApiAccessLogSampleRate(primaryZygoteState); maybeSetHiddenApiAccessLogSampleRate(primaryZygoteState);
} }
if (primaryZygoteState.matches(abi)) { if (primaryZygoteState.matches(abi)) {
return primaryZygoteState; return primaryZygoteState;
} }
@@ -608,10 +649,12 @@ public class ZygoteProcess {
// The primary zygote didn't match. Try the secondary. // The primary zygote didn't match. Try the secondary.
if (secondaryZygoteState == null || secondaryZygoteState.isClosed()) { if (secondaryZygoteState == null || secondaryZygoteState.isClosed()) {
try { try {
secondaryZygoteState = ZygoteState.connect(mSecondarySocket); secondaryZygoteState =
ZygoteState.connect(mZygoteSecondarySocketAddress);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new ZygoteStartFailedEx("Error connecting to secondary zygote", ioe); throw new ZygoteStartFailedEx("Error connecting to secondary zygote", ioe);
} }
maybeSetApiBlacklistExemptions(secondaryZygoteState, false); maybeSetApiBlacklistExemptions(secondaryZygoteState, false);
maybeSetHiddenApiAccessLogSampleRate(secondaryZygoteState); maybeSetHiddenApiAccessLogSampleRate(secondaryZygoteState);
} }
@@ -632,27 +675,27 @@ public class ZygoteProcess {
IOException { IOException {
synchronized(mLock) { synchronized(mLock) {
ZygoteState state = openZygoteSocketIfNeeded(abi); ZygoteState state = openZygoteSocketIfNeeded(abi);
state.writer.write("5"); state.mZygoteOutputWriter.write("5");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write("--preload-package"); state.mZygoteOutputWriter.write("--preload-package");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write(packagePath); state.mZygoteOutputWriter.write(packagePath);
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write(libsPath); state.mZygoteOutputWriter.write(libsPath);
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write(libFileName); state.mZygoteOutputWriter.write(libFileName);
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write(cacheKey); state.mZygoteOutputWriter.write(cacheKey);
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.flush(); state.mZygoteOutputWriter.flush();
return (state.inputStream.readInt() == 0); return (state.mZygoteInputStream.readInt() == 0);
} }
} }
@@ -666,13 +709,13 @@ public class ZygoteProcess {
synchronized (mLock) { synchronized (mLock) {
ZygoteState state = openZygoteSocketIfNeeded(abi); ZygoteState state = openZygoteSocketIfNeeded(abi);
// Each query starts with the argument count (1 in this case) // Each query starts with the argument count (1 in this case)
state.writer.write("1"); state.mZygoteOutputWriter.write("1");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.write("--preload-default"); state.mZygoteOutputWriter.write("--preload-default");
state.writer.newLine(); state.mZygoteOutputWriter.newLine();
state.writer.flush(); state.mZygoteOutputWriter.flush();
return (state.inputStream.readInt() == 0); return (state.mZygoteInputStream.readInt() == 0);
} }
} }
@@ -680,20 +723,21 @@ public class ZygoteProcess {
* Try connecting to the Zygote over and over again until we hit a time-out. * Try connecting to the Zygote over and over again until we hit a time-out.
* @param socketName The name of the socket to connect to. * @param socketName The name of the socket to connect to.
*/ */
public static void waitForConnectionToZygote(String socketName) { public static void waitForConnectionToZygote(String zygoteSocketName) {
final LocalSocketAddress address = final LocalSocketAddress zygoteSocketAddress =
new LocalSocketAddress(socketName, LocalSocketAddress.Namespace.RESERVED); new LocalSocketAddress(zygoteSocketName, LocalSocketAddress.Namespace.RESERVED);
waitForConnectionToZygote(address); waitForConnectionToZygote(zygoteSocketAddress);
} }
/** /**
* Try connecting to the Zygote over and over again until we hit a time-out. * Try connecting to the Zygote over and over again until we hit a time-out.
* @param address The name of the socket to connect to. * @param address The name of the socket to connect to.
*/ */
public static void waitForConnectionToZygote(LocalSocketAddress address) { public static void waitForConnectionToZygote(LocalSocketAddress zygoteSocketAddress) {
for (int n = 20; n >= 0; n--) { for (int n = 20; n >= 0; n--) {
try { try {
final ZygoteState zs = ZygoteState.connect(address); final ZygoteState zs =
ZygoteState.connect(zygoteSocketAddress);
zs.close(); zs.close();
return; return;
} catch (IOException ioe) { } catch (IOException ioe) {
@@ -706,7 +750,8 @@ public class ZygoteProcess {
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
} }
} }
Slog.wtf(LOG_TAG, "Failed to connect to Zygote through socket " + address.getName()); Slog.wtf(LOG_TAG, "Failed to connect to Zygote through socket "
+ zygoteSocketAddress.getName());
} }
/** /**

View File

@@ -150,7 +150,7 @@ public class WebViewZygote {
} }
try { try {
sZygote = Process.zygoteProcess.startChildZygote( sZygote = Process.ZYGOTE_PROCESS.startChildZygote(
"com.android.internal.os.WebViewZygoteInit", "com.android.internal.os.WebViewZygoteInit",
"webview_zygote", "webview_zygote",
Process.WEBVIEW_ZYGOTE_UID, Process.WEBVIEW_ZYGOTE_UID,

View File

@@ -18,7 +18,6 @@ package com.android.internal.os;
import android.app.ApplicationLoaders; import android.app.ApplicationLoaders;
import android.net.LocalSocket; import android.net.LocalSocket;
import android.net.LocalServerSocket;
import android.os.Build; import android.os.Build;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.system.Os; import android.system.Os;

View File

@@ -21,7 +21,6 @@ import static android.system.OsConstants.S_IRWXO;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.opengl.EGL14;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.os.IInstalld; import android.os.IInstalld;
@@ -853,8 +852,8 @@ public class ZygoteInit {
} }
private static void waitForSecondaryZygote(String socketName) { private static void waitForSecondaryZygote(String socketName) {
String otherZygoteName = Process.ZYGOTE_SOCKET.equals(socketName) ? String otherZygoteName = ZygoteProcess.ZYGOTE_SOCKET_NAME.equals(socketName)
Process.SECONDARY_ZYGOTE_SOCKET : Process.ZYGOTE_SOCKET; ? ZygoteProcess.ZYGOTE_SECONDARY_SOCKET_NAME : ZygoteProcess.ZYGOTE_SOCKET_NAME;
ZygoteProcess.waitForConnectionToZygote(otherZygoteName); ZygoteProcess.waitForConnectionToZygote(otherZygoteName);
} }

View File

@@ -89,7 +89,6 @@ import static android.os.Process.SCHED_OTHER;
import static android.os.Process.SCHED_RESET_ON_FORK; import static android.os.Process.SCHED_RESET_ON_FORK;
import static android.os.Process.SE_UID; import static android.os.Process.SE_UID;
import static android.os.Process.SHELL_UID; import static android.os.Process.SHELL_UID;
import static android.os.Process.SIGNAL_QUIT;
import static android.os.Process.SIGNAL_USR1; import static android.os.Process.SIGNAL_USR1;
import static android.os.Process.SYSTEM_UID; import static android.os.Process.SYSTEM_UID;
import static android.os.Process.THREAD_GROUP_BG_NONINTERACTIVE; import static android.os.Process.THREAD_GROUP_BG_NONINTERACTIVE;
@@ -98,6 +97,7 @@ import static android.os.Process.THREAD_GROUP_RESTRICTED;
import static android.os.Process.THREAD_GROUP_TOP_APP; import static android.os.Process.THREAD_GROUP_TOP_APP;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND; import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
import static android.os.Process.THREAD_PRIORITY_FOREGROUND; import static android.os.Process.THREAD_PRIORITY_FOREGROUND;
import static android.os.Process.ZYGOTE_PROCESS;
import static android.os.Process.getFreeMemory; import static android.os.Process.getFreeMemory;
import static android.os.Process.getTotalMemory; import static android.os.Process.getTotalMemory;
import static android.os.Process.isThreadInProcess; import static android.os.Process.isThreadInProcess;
@@ -112,7 +112,6 @@ import static android.os.Process.setProcessGroup;
import static android.os.Process.setThreadPriority; import static android.os.Process.setThreadPriority;
import static android.os.Process.setThreadScheduler; import static android.os.Process.setThreadScheduler;
import static android.os.Process.startWebView; import static android.os.Process.startWebView;
import static android.os.Process.zygoteProcess;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
import static android.provider.Settings.Global.ALWAYS_FINISH_ACTIVITIES; import static android.provider.Settings.Global.ALWAYS_FINISH_ACTIVITIES;
import static android.provider.Settings.Global.DEBUG_APP; import static android.provider.Settings.Global.DEBUG_APP;
@@ -127,6 +126,12 @@ import static android.service.voice.VoiceInteractionSession.SHOW_SOURCE_APPLICAT
import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_TASK_IN_PLACE;
import static android.view.WindowManager.TRANSIT_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT;
import static com.android.internal.util.XmlUtils.readBooleanAttribute; import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute; import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readLongAttribute; import static com.android.internal.util.XmlUtils.readLongAttribute;
@@ -197,19 +202,15 @@ import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS
import static com.android.server.am.ActivityStackSupervisor.ON_TOP; import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS; import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.am.ActivityStackSupervisor.REMOVE_FROM_RECENTS; import static com.android.server.am.ActivityStackSupervisor.REMOVE_FROM_RECENTS;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
import static com.android.server.am.MemoryStatUtil.hasMemcg; import static com.android.server.am.MemoryStatUtil.hasMemcg;
import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem;
import static com.android.server.am.TaskRecord.INVALID_TASK_ID; import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.am.TaskRecord.REPARENT_KEEP_STACK_AT_FRONT; import static com.android.server.am.TaskRecord.REPARENT_KEEP_STACK_AT_FRONT;
import static com.android.server.am.TaskRecord.REPARENT_LEAVE_STACK_IN_PLACE; import static com.android.server.am.TaskRecord.REPARENT_LEAVE_STACK_IN_PLACE;
import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_TASK_IN_PLACE;
import static android.view.WindowManager.TRANSIT_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT;
import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION;
import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT; import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
@@ -326,7 +327,6 @@ import android.os.Debug;
import android.os.DropBoxManager; import android.os.DropBoxManager;
import android.os.Environment; import android.os.Environment;
import android.os.FactoryTest; import android.os.FactoryTest;
import android.os.FileObserver;
import android.os.FileUtils; import android.os.FileUtils;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
@@ -416,12 +416,12 @@ import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BackgroundThread; import com.android.internal.os.BackgroundThread;
import com.android.internal.os.BatteryStatsImpl; import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.os.BinderInternal; import com.android.internal.os.BinderInternal;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.internal.os.ByteTransferPipe; import com.android.internal.os.ByteTransferPipe;
import com.android.internal.os.IResultReceiver; import com.android.internal.os.IResultReceiver;
import com.android.internal.os.ProcessCpuTracker; import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.TransferPipe; import com.android.internal.os.TransferPipe;
import com.android.internal.os.Zygote; import com.android.internal.os.Zygote;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.KeyguardDismissCallback; import com.android.internal.policy.KeyguardDismissCallback;
import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents;
@@ -448,17 +448,16 @@ import com.android.server.SystemService;
import com.android.server.SystemServiceManager; import com.android.server.SystemServiceManager;
import com.android.server.ThreadPriorityBooster; import com.android.server.ThreadPriorityBooster;
import com.android.server.Watchdog; import com.android.server.Watchdog;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.am.MemoryStatUtil.MemoryStat;
import com.android.server.am.ActivityManagerServiceProto;
import com.android.server.am.ActivityManagerServiceDumpActivitiesProto; import com.android.server.am.ActivityManagerServiceDumpActivitiesProto;
import com.android.server.am.ActivityManagerServiceDumpBroadcastsProto; import com.android.server.am.ActivityManagerServiceDumpBroadcastsProto;
import com.android.server.am.ActivityManagerServiceDumpProcessesProto; import com.android.server.am.ActivityManagerServiceDumpProcessesProto;
import com.android.server.am.ActivityManagerServiceDumpProcessesProto.UidObserverRegistrationProto; import com.android.server.am.ActivityManagerServiceDumpProcessesProto.UidObserverRegistrationProto;
import com.android.server.am.ActivityManagerServiceDumpServicesProto; import com.android.server.am.ActivityManagerServiceDumpServicesProto;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.am.GrantUriProto; import com.android.server.am.GrantUriProto;
import com.android.server.am.ImportanceTokenProto; import com.android.server.am.ImportanceTokenProto;
import com.android.server.am.MemInfoDumpProto; import com.android.server.am.MemInfoDumpProto;
import com.android.server.am.MemoryStatUtil.MemoryStat;
import com.android.server.am.NeededUriGrantsProto; import com.android.server.am.NeededUriGrantsProto;
import com.android.server.am.ProcessOomProto; import com.android.server.am.ProcessOomProto;
import com.android.server.am.ProcessToGcProto; import com.android.server.am.ProcessToGcProto;
@@ -475,12 +474,12 @@ import com.android.server.wm.WindowManagerService;
import dalvik.system.VMRuntime; import dalvik.system.VMRuntime;
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
import com.google.android.collect.Lists; import com.google.android.collect.Lists;
import com.google.android.collect.Maps; import com.google.android.collect.Maps;
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
@@ -2958,7 +2957,7 @@ public class ActivityManagerService extends IActivityManager.Stub
? Collections.emptyList() ? Collections.emptyList()
: Arrays.asList(exemptions.split(",")); : Arrays.asList(exemptions.split(","));
} }
if (!zygoteProcess.setApiBlacklistExemptions(mExemptions)) { if (!ZYGOTE_PROCESS.setApiBlacklistExemptions(mExemptions)) {
Slog.e(TAG, "Failed to set API blacklist exemptions!"); Slog.e(TAG, "Failed to set API blacklist exemptions!");
// leave mExemptionsStr as is, so we don't try to send the same list again. // leave mExemptionsStr as is, so we don't try to send the same list again.
mExemptions = Collections.emptyList(); mExemptions = Collections.emptyList();
@@ -2971,7 +2970,7 @@ public class ActivityManagerService extends IActivityManager.Stub
} }
if (logSampleRate != -1 && logSampleRate != mLogSampleRate) { if (logSampleRate != -1 && logSampleRate != mLogSampleRate) {
mLogSampleRate = logSampleRate; mLogSampleRate = logSampleRate;
zygoteProcess.setHiddenApiAccessLogSampleRate(mLogSampleRate); ZYGOTE_PROCESS.setHiddenApiAccessLogSampleRate(mLogSampleRate);
} }
mPolicy = getValidEnforcementPolicy(Settings.Global.HIDDEN_API_POLICY); mPolicy = getValidEnforcementPolicy(Settings.Global.HIDDEN_API_POLICY);
} }
@@ -7882,7 +7881,7 @@ public class ActivityManagerService extends IActivityManager.Stub
ArraySet<String> completedIsas = new ArraySet<String>(); ArraySet<String> completedIsas = new ArraySet<String>();
for (String abi : Build.SUPPORTED_ABIS) { for (String abi : Build.SUPPORTED_ABIS) {
zygoteProcess.establishZygoteConnectionForAbi(abi); ZYGOTE_PROCESS.establishZygoteConnectionForAbi(abi);
final String instructionSet = VMRuntime.getInstructionSet(abi); final String instructionSet = VMRuntime.getInstructionSet(abi);
if (!completedIsas.contains(instructionSet)) { if (!completedIsas.contains(instructionSet)) {
try { try {

View File

@@ -803,7 +803,7 @@ public final class SystemServer {
TimingsTraceLog traceLog = new TimingsTraceLog( TimingsTraceLog traceLog = new TimingsTraceLog(
SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER); SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
traceLog.traceBegin(SECONDARY_ZYGOTE_PRELOAD); traceLog.traceBegin(SECONDARY_ZYGOTE_PRELOAD);
if (!Process.zygoteProcess.preloadDefault(Build.SUPPORTED_32_BIT_ABIS[0])) { if (!Process.ZYGOTE_PROCESS.preloadDefault(Build.SUPPORTED_32_BIT_ABIS[0])) {
Slog.e(TAG, "Unable to preload default resources"); Slog.e(TAG, "Unable to preload default resources");
} }
traceLog.traceEnd(); traceLog.traceEnd();