Renamed blastula to unspecialized app process (usap)
Bug: 123017829
Test: make & boot & launch apps
Change-Id: Icfb9f8f4ebabacece817735d60d232cf3afb4e08
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 0ccaec0..2bba3c9 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -126,8 +126,8 @@
/** Read-write external storage should be mounted instead of package sandbox */
public static final int MOUNT_EXTERNAL_FULL = IVold.REMOUNT_MODE_FULL;
- /** Number of bytes sent to the Zygote over blastula pipes or the pool event FD */
- public static final int BLASTULA_MANAGEMENT_MESSAGE_BYTES = 8;
+ /** Number of bytes sent to the Zygote over USAP pipes or the pool event FD */
+ public static final int USAP_MANAGEMENT_MESSAGE_BYTES = 8;
/**
* An extraArg passed when a zygote process is forking a child-zygote, specifying a name
@@ -187,12 +187,12 @@
/**
* @hide for internal use only
*/
- public static final String BLASTULA_POOL_PRIMARY_SOCKET_NAME = "blastula_pool";
+ public static final String USAP_POOL_PRIMARY_SOCKET_NAME = "usap_pool_primary";
/**
* @hide for internal use only
*/
- public static final String BLASTULA_POOL_SECONDARY_SOCKET_NAME = "blastula_pool_secondary";
+ public static final String USAP_POOL_SECONDARY_SOCKET_NAME = "usap_pool_secondary";
private Zygote() {}
@@ -262,7 +262,7 @@
String sandboxId);
/**
- * Specialize a Blastula instance. The current VM must have been started
+ * Specialize an unspecialized app process. The current VM must have been started
* with the -Xzygote flag.
*
* @param uid The UNIX uid that the new process should setuid() to before spawning any threads
@@ -282,12 +282,11 @@
* @param instructionSet null-ok The instruction set to use.
* @param appDataDir null-ok The data directory of the app.
*/
- public static void specializeBlastula(int uid, int gid, int[] gids, int runtimeFlags,
+ public static void specializeAppProcess(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName,
boolean startChildZygote, String instructionSet, String appDataDir, String packageName,
String[] packagesForUID, String sandboxId) {
-
- nativeSpecializeBlastula(uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo,
+ nativeSpecializeAppProcess(uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo,
niceName, startChildZygote, instructionSet, appDataDir,
packageName, packagesForUID, sandboxId);
@@ -306,7 +305,7 @@
ZygoteHooks.postForkCommon();
}
- private static native void nativeSpecializeBlastula(int uid, int gid, int[] gids,
+ private static native void nativeSpecializeAppProcess(int uid, int gid, int[] gids,
int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName,
boolean startChildZygote, String instructionSet, String appDataDir, String packageName,
String[] packagesForUID, String sandboxId);
@@ -427,11 +426,11 @@
defaultValue);
}
- protected static void emptyBlastulaPool() {
- nativeEmptyBlastulaPool();
+ protected static void emptyUsapPool() {
+ nativeEmptyUsapPool();
}
- private static native void nativeEmptyBlastulaPool();
+ private static native void nativeEmptyUsapPool();
/**
* Returns the value of a system property converted to a boolean using specific logic.
@@ -454,105 +453,105 @@
}
/**
- * @return Number of blastulas currently in the pool
+ * @return Number of unspecialized app processes currently in the pool
*/
- static int getBlastulaPoolCount() {
- return nativeGetBlastulaPoolCount();
+ static int getUsapPoolCount() {
+ return nativeGetUsapPoolCount();
}
- private static native int nativeGetBlastulaPoolCount();
+ private static native int nativeGetUsapPoolCount();
/**
* @return The event FD used for communication between the signal handler and the ZygoteServer
* poll loop
*/
- static FileDescriptor getBlastulaPoolEventFD() {
+ static FileDescriptor getUsapPoolEventFD() {
FileDescriptor fd = new FileDescriptor();
- fd.setInt$(nativeGetBlastulaPoolEventFD());
+ fd.setInt$(nativeGetUsapPoolEventFD());
return fd;
}
- private static native int nativeGetBlastulaPoolEventFD();
+ private static native int nativeGetUsapPoolEventFD();
/**
- * Fork a new blastula process from the zygote
+ * Fork a new unspecialized app process from the zygote
*
* @param sessionSocketRawFDs Anonymous session sockets that are currently open
- * @return In the Zygote process this function will always return null; in blastula processes
- * this function will return a Runnable object representing the new application that is
- * passed up from blastulaMain.
+ * @return In the Zygote process this function will always return null; in unspecialized app
+ * processes this function will return a Runnable object representing the new
+ * application that is passed up from usapMain.
*/
- static Runnable forkBlastula(LocalServerSocket blastulaPoolSocket,
- int[] sessionSocketRawFDs) {
+ static Runnable forkUsap(LocalServerSocket usapPoolSocket,
+ int[] sessionSocketRawFDs) {
FileDescriptor[] pipeFDs = null;
try {
pipeFDs = Os.pipe2(O_CLOEXEC);
} catch (ErrnoException errnoEx) {
- throw new IllegalStateException("Unable to create blastula pipe.", errnoEx);
+ throw new IllegalStateException("Unable to create USAP pipe.", errnoEx);
}
int pid =
- nativeForkBlastula(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), sessionSocketRawFDs);
+ nativeForkUsap(pipeFDs[0].getInt$(), pipeFDs[1].getInt$(), sessionSocketRawFDs);
if (pid == 0) {
IoUtils.closeQuietly(pipeFDs[0]);
- return blastulaMain(blastulaPoolSocket, pipeFDs[1]);
+ return usapMain(usapPoolSocket, pipeFDs[1]);
} else {
// The read-end of the pipe will be closed by the native code.
- // See removeBlastulaTableEntry();
+ // See removeUsapTableEntry();
IoUtils.closeQuietly(pipeFDs[1]);
return null;
}
}
- private static native int nativeForkBlastula(int readPipeFD,
+ private static native int nativeForkUsap(int readPipeFD,
int writePipeFD,
int[] sessionSocketRawFDs);
/**
- * This function is used by blastulas to wait for specialization requests from the system
- * server.
+ * This function is used by unspecialized app processes to wait for specialization requests from
+ * the system server.
*
* @param writePipe The write end of the reporting pipe used to communicate with the poll loop
* of the ZygoteServer.
* @return A runnable oject representing the new application.
*/
- private static Runnable blastulaMain(LocalServerSocket blastulaPoolSocket,
- FileDescriptor writePipe) {
+ private static Runnable usapMain(LocalServerSocket usapPoolSocket,
+ FileDescriptor writePipe) {
final int pid = Process.myPid();
LocalSocket sessionSocket = null;
- DataOutputStream blastulaOutputStream = null;
+ DataOutputStream usapOutputStream = null;
Credentials peerCredentials = null;
ZygoteArguments args = null;
while (true) {
try {
- sessionSocket = blastulaPoolSocket.accept();
+ sessionSocket = usapPoolSocket.accept();
- BufferedReader blastulaReader =
+ BufferedReader usapReader =
new BufferedReader(new InputStreamReader(sessionSocket.getInputStream()));
- blastulaOutputStream =
+ usapOutputStream =
new DataOutputStream(sessionSocket.getOutputStream());
peerCredentials = sessionSocket.getPeerCredentials();
- String[] argStrings = readArgumentList(blastulaReader);
+ String[] argStrings = readArgumentList(usapReader);
if (argStrings != null) {
args = new ZygoteArguments(argStrings);
// TODO (chriswailes): Should this only be run for debug builds?
- validateBlastulaCommand(args);
+ validateUsapCommand(args);
break;
} else {
- Log.e("Blastula", "Truncated command received.");
+ Log.e("USAP", "Truncated command received.");
IoUtils.closeQuietly(sessionSocket);
}
} catch (Exception ex) {
- Log.e("Blastula", ex.getMessage());
+ Log.e("USAP", ex.getMessage());
IoUtils.closeQuietly(sessionSocket);
}
}
@@ -571,29 +570,29 @@
try {
// Used by ZygoteProcess.zygoteSendArgsAndGetResult to fill in a
// Process.ProcessStartResult object.
- blastulaOutputStream.writeInt(pid);
+ usapOutputStream.writeInt(pid);
} catch (IOException ioEx) {
- Log.e("Blastula", "Failed to write response to session socket: " + ioEx.getMessage());
+ Log.e("USAP", "Failed to write response to session socket: " + ioEx.getMessage());
System.exit(-1);
} finally {
IoUtils.closeQuietly(sessionSocket);
- IoUtils.closeQuietly(blastulaPoolSocket);
+ IoUtils.closeQuietly(usapPoolSocket);
}
try {
ByteArrayOutputStream buffer =
- new ByteArrayOutputStream(Zygote.BLASTULA_MANAGEMENT_MESSAGE_BYTES);
+ new ByteArrayOutputStream(Zygote.USAP_MANAGEMENT_MESSAGE_BYTES);
DataOutputStream outputStream = new DataOutputStream(buffer);
- // This is written as a long so that the blastula reporting pipe and blastula pool
- // event FD handlers in ZygoteServer.runSelectLoop can be unified. These two cases
- // should both send/receive 8 bytes.
+ // This is written as a long so that the USAP reporting pipe and USAP pool event FD
+ // handlers in ZygoteServer.runSelectLoop can be unified. These two cases should both
+ // send/receive 8 bytes.
outputStream.writeLong(pid);
outputStream.flush();
Os.write(writePipe, buffer.toByteArray(), 0, buffer.size());
} catch (Exception ex) {
- Log.e("Blastula",
+ Log.e("USAP",
String.format("Failed to write PID (%d) to pipe (%d): %s",
pid, writePipe.getInt$(), ex.getMessage()));
System.exit(-1);
@@ -601,7 +600,7 @@
IoUtils.closeQuietly(writePipe);
}
- specializeBlastula(args.mUid, args.mGid, args.mGids,
+ specializeAppProcess(args.mUid, args.mGid, args.mGids,
args.mRuntimeFlags, rlimits, args.mMountExternal,
args.mSeInfo, args.mNiceName, args.mStartChildZygote,
args.mInstructionSet, args.mAppDataDir, args.mPackageName,
@@ -619,37 +618,37 @@
null /* classLoader */);
}
- private static final String BLASTULA_ERROR_PREFIX = "Invalid command to blastula: ";
+ private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: ";
/**
- * Checks a set of zygote arguments to see if they can be handled by a blastula. Throws an
+ * Checks a set of zygote arguments to see if they can be handled by a USAP. Throws an
* exception if an invalid arugment is encountered.
* @param args The arguments to test
*/
- private static void validateBlastulaCommand(ZygoteArguments args) {
+ private static void validateUsapCommand(ZygoteArguments args) {
if (args.mAbiListQuery) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--query-abi-list");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--query-abi-list");
} else if (args.mPidQuery) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--get-pid");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--get-pid");
} else if (args.mPreloadDefault) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--preload-default");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--preload-default");
} else if (args.mPreloadPackage != null) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--preload-package");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--preload-package");
} else if (args.mPreloadApp != null) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--preload-app");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--preload-app");
} else if (args.mStartChildZygote) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--start-child-zygote");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--start-child-zygote");
} else if (args.mApiBlacklistExemptions != null) {
throw new IllegalArgumentException(
- BLASTULA_ERROR_PREFIX + "--set-api-blacklist-exemptions");
+ USAP_ERROR_PREFIX + "--set-api-blacklist-exemptions");
} else if (args.mHiddenApiAccessLogSampleRate != -1) {
throw new IllegalArgumentException(
- BLASTULA_ERROR_PREFIX + "--hidden-api-log-sampling-rate=");
+ USAP_ERROR_PREFIX + "--hidden-api-log-sampling-rate=");
} else if (args.mHiddenApiAccessStatslogSampleRate != -1) {
throw new IllegalArgumentException(
- BLASTULA_ERROR_PREFIX + "--hidden-api-statslog-sampling-rate=");
+ USAP_ERROR_PREFIX + "--hidden-api-statslog-sampling-rate=");
} else if (args.mInvokeWith != null) {
- throw new IllegalArgumentException(BLASTULA_ERROR_PREFIX + "--invoke-with");
+ throw new IllegalArgumentException(USAP_ERROR_PREFIX + "--invoke-with");
} else if (args.mPermittedCapabilities != 0 || args.mEffectiveCapabilities != 0) {
throw new ZygoteSecurityException("Client may not specify capabilities: "
+ "permitted=0x" + Long.toHexString(args.mPermittedCapabilities)
@@ -658,25 +657,25 @@
}
/**
- * @return Raw file descriptors for the read-end of blastula reporting pipes.
+ * @return Raw file descriptors for the read-end of USAP reporting pipes.
*/
- protected static int[] getBlastulaPipeFDs() {
- return nativeGetBlastulaPipeFDs();
+ protected static int[] getUsapPipeFDs() {
+ return nativeGetUsapPipeFDs();
}
- private static native int[] nativeGetBlastulaPipeFDs();
+ private static native int[] nativeGetUsapPipeFDs();
/**
- * Remove the blastula table entry for the provided process ID.
+ * Remove the USAP table entry for the provided process ID.
*
- * @param blastulaPID Process ID of the entry to remove
+ * @param usapPID Process ID of the entry to remove
* @return True if the entry was removed; false if it doesn't exist
*/
- protected static boolean removeBlastulaTableEntry(int blastulaPID) {
- return nativeRemoveBlastulaTableEntry(blastulaPID);
+ protected static boolean removeUsapTableEntry(int usapPID) {
+ return nativeRemoveUsapTableEntry(usapPID);
}
- private static native boolean nativeRemoveBlastulaTableEntry(int blastulaPID);
+ private static native boolean nativeRemoveUsapTableEntry(int usapPID);
/**
* uid 1000 (Process.SYSTEM_UID) may specify any uid > 1000 in normal
diff --git a/core/java/com/android/internal/os/ZygoteArguments.java b/core/java/com/android/internal/os/ZygoteArguments.java
index 3beee78..28642d8 100644
--- a/core/java/com/android/internal/os/ZygoteArguments.java
+++ b/core/java/com/android/internal/os/ZygoteArguments.java
@@ -103,8 +103,8 @@
/**
*
*/
- boolean mBlastulaPoolEnabled;
- boolean mBlastulaPoolStatusSpecified = false;
+ boolean mUsapPoolEnabled;
+ boolean mUsapPoolStatusSpecified = false;
/**
* from all --rlimit=r,c,m
@@ -418,9 +418,9 @@
throw new IllegalArgumentException("Duplicate arg specified");
}
mSandboxId = arg.substring(arg.indexOf('=') + 1);
- } else if (arg.startsWith("--blastula-pool-enabled=")) {
- mBlastulaPoolStatusSpecified = true;
- mBlastulaPoolEnabled = Boolean.parseBoolean(arg.substring(arg.indexOf('=') + 1));
+ } else if (arg.startsWith("--usap-pool-enabled=")) {
+ mUsapPoolStatusSpecified = true;
+ mUsapPoolEnabled = Boolean.parseBoolean(arg.substring(arg.indexOf('=') + 1));
expectRuntimeArgs = false;
} else {
break;
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index bcdce31..87adce7 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -159,8 +159,8 @@
return null;
}
- if (parsedArgs.mBlastulaPoolStatusSpecified) {
- return handleBlastulaPoolStatusChange(zygoteServer, parsedArgs.mBlastulaPoolEnabled);
+ if (parsedArgs.mUsapPoolStatusSpecified) {
+ return handleUsapPoolStatusChange(zygoteServer, parsedArgs.mUsapPoolEnabled);
}
if (parsedArgs.mPreloadDefault) {
@@ -331,18 +331,18 @@
}
}
- private Runnable stateChangeWithBlastulaPoolReset(ZygoteServer zygoteServer,
+ private Runnable stateChangeWithUsapPoolReset(ZygoteServer zygoteServer,
Runnable stateChangeCode) {
try {
- if (zygoteServer.isBlastulaPoolEnabled()) {
- Zygote.emptyBlastulaPool();
+ if (zygoteServer.isUsapPoolEnabled()) {
+ Zygote.emptyUsapPool();
}
stateChangeCode.run();
- if (zygoteServer.isBlastulaPoolEnabled()) {
+ if (zygoteServer.isUsapPoolEnabled()) {
Runnable fpResult =
- zygoteServer.fillBlastulaPool(
+ zygoteServer.fillUsapPool(
new int[]{mSocket.getFileDescriptor().getInt$()});
if (fpResult != null) {
@@ -363,24 +363,24 @@
* Makes the necessary changes to implement a new API blacklist exemption policy, and then
* responds to the system server, letting it know that the task has been completed.
*
- * This necessitates a change to the internal state of the Zygote. As such, if the blastula
- * pool is enabled all existing blastulas have an incorrect API blacklist exemption list. To
+ * This necessitates a change to the internal state of the Zygote. As such, if the USAP
+ * pool is enabled all existing USAPs have an incorrect API blacklist exemption list. To
* properly handle this request the pool must be emptied and refilled. This process can return
* a Runnable object that must be returned to ZygoteServer.runSelectLoop to be invoked.
*
* @param zygoteServer The server object that received the request
* @param exemptions The new exemption list.
- * @return A Runnable object representing a new app in any blastulas spawned from here; the
+ * @return A Runnable object representing a new app in any USAPs spawned from here; the
* zygote process will always receive a null value from this function.
*/
private Runnable handleApiBlacklistExemptions(ZygoteServer zygoteServer, String[] exemptions) {
- return stateChangeWithBlastulaPoolReset(zygoteServer,
+ return stateChangeWithUsapPoolReset(zygoteServer,
() -> ZygoteInit.setApiBlacklistExemptions(exemptions));
}
- private Runnable handleBlastulaPoolStatusChange(ZygoteServer zygoteServer, boolean newStatus) {
+ private Runnable handleUsapPoolStatusChange(ZygoteServer zygoteServer, boolean newStatus) {
try {
- Runnable fpResult = zygoteServer.setBlastulaPoolStatus(newStatus, mSocket);
+ Runnable fpResult = zygoteServer.setUsapPoolStatus(newStatus, mSocket);
if (fpResult == null) {
mSocketOutStream.writeInt(0);
@@ -473,8 +473,8 @@
/**
* Changes the API access log sample rate for the Zygote and processes spawned from it.
*
- * This necessitates a change to the internal state of the Zygote. As such, if the blastula
- * pool is enabled all existing blastulas have an incorrect API access log sample rate. To
+ * This necessitates a change to the internal state of the Zygote. As such, if the USAP
+ * pool is enabled all existing USAPs have an incorrect API access log sample rate. To
* properly handle this request the pool must be emptied and refilled. This process can return
* a Runnable object that must be returned to ZygoteServer.runSelectLoop to be invoked.
*
@@ -486,11 +486,10 @@
*/
private Runnable handleHiddenApiAccessLogSampleRate(ZygoteServer zygoteServer,
int samplingRate, int statsdSamplingRate) {
- return stateChangeWithBlastulaPoolReset(zygoteServer, () -> {
+ return stateChangeWithUsapPoolReset(zygoteServer, () -> {
int maxSamplingRate = Math.max(samplingRate, statsdSamplingRate);
ZygoteInit.setHiddenApiAccessLogSampleRate(maxSamplingRate);
- HiddenApiUsageLogger.setHiddenApiAccessLogSampleRates(samplingRate,
- statsdSamplingRate);
+ HiddenApiUsageLogger.setHiddenApiAccessLogSampleRates(samplingRate, statsdSamplingRate);
ZygoteInit.setHiddenApiUsageLogger(HiddenApiUsageLogger.getInstance());
});
}
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 7cddf75..a5e7202 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -99,7 +99,7 @@
private static final String ABI_LIST_ARG = "--abi-list=";
// TODO (chriswailes): Re-name this --zygote-socket-name= and then add a
- // --blastula-socket-name parameter.
+ // --usap-socket-name parameter.
private static final String SOCKET_NAME_ARG = "--socket-name=";
/**
diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java
index c4c98ba..6595317 100644
--- a/core/java/com/android/internal/os/ZygoteServer.java
+++ b/core/java/com/android/internal/os/ZygoteServer.java
@@ -51,39 +51,40 @@
public static final String TAG = "ZygoteServer";
/**
- * The maximim value that will be accepted from the BLASTULA_POOL_SIZE_MAX device property.
- * is a mirror of BLASTULA_POOL_MAX_LIMIT found in com_android_internal_os_Zygote.cpp.
+ * The maximim value that will be accepted from the USAP_POOL_SIZE_MAX device property.
+ * is a mirror of USAP_POOL_MAX_LIMIT found in com_android_internal_os_Zygote.cpp.
*/
- private static final int BLASTULA_POOL_SIZE_MAX_LIMIT = 100;
+ private static final int USAP_POOL_SIZE_MAX_LIMIT = 100;
/**
- * The minimum value that will be accepted from the BLASTULA_POOL_SIZE_MIN device property.
+ * The minimum value that will be accepted from the USAP_POOL_SIZE_MIN device property.
*/
- private static final int BLASTULA_POOL_SIZE_MIN_LIMIT = 1;
+ private static final int USAP_POOL_SIZE_MIN_LIMIT = 1;
- /** The default value used for the BLASTULA_POOL_SIZE_MAX device property */
- private static final String BLASTULA_POOL_SIZE_MAX_DEFAULT = "10";
+ /** The default value used for the USAP_POOL_SIZE_MAX device property */
+ private static final String USAP_POOL_SIZE_MAX_DEFAULT = "10";
- /** The default value used for the BLASTULA_POOL_SIZE_MIN device property */
- private static final String BLASTULA_POOL_SIZE_MIN_DEFAULT = "1";
+ /** The default value used for the USAP_POOL_SIZE_MIN device property */
+ private static final String USAP_POOL_SIZE_MIN_DEFAULT = "1";
/**
- * Indicates if this Zygote server can support a blastula pool. Currently this should only be
- * true for the primary and secondary Zygotes, and not the App Zygotes or the WebView Zygote.
+ * Indicates if this Zygote server can support a unspecialized app process pool. Currently this
+ * should only be true for the primary and secondary Zygotes, and not the App Zygotes or the
+ * WebView Zygote.
*
* TODO (chriswailes): Make this an explicit argument to the constructor
*/
- private final boolean mBlastulaPoolSupported;
+ private final boolean mUsapPoolSupported;
/**
- * If the blastula pool should be created and used to start applications.
+ * If the unspecialized app process pool should be created and used to start applications.
*
- * Setting this value to false will disable the creation, maintenance, and use of the blastula
- * pool. When the blastula pool is disabled the application lifecycle will be identical to
+ * Setting this value to false will disable the creation, maintenance, and use of the USAP
+ * pool. When the USAP pool is disabled the application lifecycle will be identical to
* previous versions of Android.
*/
- private boolean mBlastulaPoolEnabled = false;
+ private boolean mUsapPoolEnabled = false;
/**
* Listening socket that accepts new server connections.
@@ -91,15 +92,15 @@
private LocalServerSocket mZygoteSocket;
/**
- * The name of the blastula socket to use if the blastula pool is enabled.
+ * The name of the unspecialized app process pool socket to use if the USAP pool is enabled.
*/
- private LocalServerSocket mBlastulaPoolSocket;
+ private LocalServerSocket mUsapPoolSocket;
/**
* File descriptor used for communication between the signal handler and the ZygoteServer poll
* loop.
* */
- private FileDescriptor mBlastulaPoolEventFD;
+ private FileDescriptor mUsapPoolEventFD;
/**
* Whether or not mZygoteSocket's underlying FD should be closed directly.
@@ -116,62 +117,61 @@
private boolean mIsForkChild;
/**
- * The runtime-adjustable maximum Blastula pool size.
+ * The runtime-adjustable maximum USAP pool size.
*/
- private int mBlastulaPoolSizeMax = 0;
+ private int mUsapPoolSizeMax = 0;
/**
- * The runtime-adjustable minimum Blastula pool size.
+ * The runtime-adjustable minimum USAP pool size.
*/
- private int mBlastulaPoolSizeMin = 0;
+ private int mUsapPoolSizeMin = 0;
/**
- * The runtime-adjustable value used to determine when to re-fill the
- * blastula pool. The pool will be re-filled when
- * (sBlastulaPoolMax - gBlastulaPoolCount) >= sBlastulaPoolRefillThreshold.
+ * The runtime-adjustable value used to determine when to re-fill the USAP pool. The pool will
+ * be re-filled when (mUsapPoolMax - gUsapPoolCount) >= sUsapPoolRefillThreshold.
*/
- private int mBlastulaPoolRefillThreshold = 0;
+ private int mUsapPoolRefillThreshold = 0;
ZygoteServer() {
- mBlastulaPoolEventFD = null;
+ mUsapPoolEventFD = null;
mZygoteSocket = null;
- mBlastulaPoolSocket = null;
+ mUsapPoolSocket = null;
- mBlastulaPoolSupported = false;
+ mUsapPoolSupported = false;
}
/**
- * Initialize the Zygote server with the Zygote server socket, blastula pool server socket,
- * and blastula pool event FD.
+ * Initialize the Zygote server with the Zygote server socket, USAP pool server socket, and USAP
+ * pool event FD.
*
* @param isPrimaryZygote If this is the primary Zygote or not.
*/
ZygoteServer(boolean isPrimaryZygote) {
- mBlastulaPoolEventFD = Zygote.getBlastulaPoolEventFD();
+ mUsapPoolEventFD = Zygote.getUsapPoolEventFD();
if (isPrimaryZygote) {
mZygoteSocket = Zygote.createManagedSocketFromInitSocket(Zygote.PRIMARY_SOCKET_NAME);
- mBlastulaPoolSocket =
+ mUsapPoolSocket =
Zygote.createManagedSocketFromInitSocket(
- Zygote.BLASTULA_POOL_PRIMARY_SOCKET_NAME);
+ Zygote.USAP_POOL_PRIMARY_SOCKET_NAME);
} else {
mZygoteSocket = Zygote.createManagedSocketFromInitSocket(Zygote.SECONDARY_SOCKET_NAME);
- mBlastulaPoolSocket =
+ mUsapPoolSocket =
Zygote.createManagedSocketFromInitSocket(
- Zygote.BLASTULA_POOL_SECONDARY_SOCKET_NAME);
+ Zygote.USAP_POOL_SECONDARY_SOCKET_NAME);
}
- fetchBlastulaPoolPolicyProps();
+ fetchUsapPoolPolicyProps();
- mBlastulaPoolSupported = true;
+ mUsapPoolSupported = true;
}
void setForkChild() {
mIsForkChild = true;
}
- public boolean isBlastulaPoolEnabled() {
- return mBlastulaPoolEnabled;
+ public boolean isUsapPoolEnabled() {
+ return mUsapPoolEnabled;
}
/**
@@ -240,95 +240,95 @@
return mZygoteSocket.getFileDescriptor();
}
- private void fetchBlastulaPoolPolicyProps() {
- if (mBlastulaPoolSupported) {
- final String blastulaPoolSizeMaxPropString =
+ private void fetchUsapPoolPolicyProps() {
+ if (mUsapPoolSupported) {
+ final String usapPoolSizeMaxPropString =
Zygote.getSystemProperty(
- DeviceConfig.RuntimeNative.BLASTULA_POOL_SIZE_MAX,
- BLASTULA_POOL_SIZE_MAX_DEFAULT);
+ DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MAX,
+ USAP_POOL_SIZE_MAX_DEFAULT);
- if (!blastulaPoolSizeMaxPropString.isEmpty()) {
- mBlastulaPoolSizeMax =
+ if (!usapPoolSizeMaxPropString.isEmpty()) {
+ mUsapPoolSizeMax =
Integer.min(
- Integer.parseInt(blastulaPoolSizeMaxPropString),
- BLASTULA_POOL_SIZE_MAX_LIMIT);
+ Integer.parseInt(usapPoolSizeMaxPropString),
+ USAP_POOL_SIZE_MAX_LIMIT);
}
- final String blastulaPoolSizeMinPropString =
+ final String usapPoolSizeMinPropString =
Zygote.getSystemProperty(
- DeviceConfig.RuntimeNative.BLASTULA_POOL_SIZE_MIN,
- BLASTULA_POOL_SIZE_MIN_DEFAULT);
+ DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MIN,
+ USAP_POOL_SIZE_MIN_DEFAULT);
- if (!blastulaPoolSizeMinPropString.isEmpty()) {
- mBlastulaPoolSizeMin =
+ if (!usapPoolSizeMinPropString.isEmpty()) {
+ mUsapPoolSizeMin =
Integer.max(
- Integer.parseInt(blastulaPoolSizeMinPropString),
- BLASTULA_POOL_SIZE_MIN_LIMIT);
+ Integer.parseInt(usapPoolSizeMinPropString),
+ USAP_POOL_SIZE_MIN_LIMIT);
}
- final String blastulaPoolRefillThresholdPropString =
+ final String usapPoolRefillThresholdPropString =
Zygote.getSystemProperty(
- DeviceConfig.RuntimeNative.BLASTULA_POOL_REFILL_THRESHOLD,
- Integer.toString(mBlastulaPoolSizeMax / 2));
+ DeviceConfig.RuntimeNative.USAP_POOL_REFILL_THRESHOLD,
+ Integer.toString(mUsapPoolSizeMax / 2));
- if (!blastulaPoolRefillThresholdPropString.isEmpty()) {
- mBlastulaPoolRefillThreshold =
+ if (!usapPoolRefillThresholdPropString.isEmpty()) {
+ mUsapPoolRefillThreshold =
Integer.min(
- Integer.parseInt(blastulaPoolRefillThresholdPropString),
- mBlastulaPoolSizeMax);
+ Integer.parseInt(usapPoolRefillThresholdPropString),
+ mUsapPoolSizeMax);
}
}
}
private long mLastPropCheckTimestamp = 0;
- private void fetchBlastulaPoolPolicyPropsWithMinInterval() {
+ private void fetchUsapPoolPolicyPropsWithMinInterval() {
final long currentTimestamp = SystemClock.elapsedRealtime();
if (currentTimestamp - mLastPropCheckTimestamp >= Zygote.PROPERTY_CHECK_INTERVAL) {
- fetchBlastulaPoolPolicyProps();
+ fetchUsapPoolPolicyProps();
mLastPropCheckTimestamp = currentTimestamp;
}
}
/**
- * Checks to see if the current policy says that pool should be refilled, and spawns new
- * blastulas if necessary.
+ * Checks to see if the current policy says that pool should be refilled, and spawns new USAPs
+ * if necessary.
*
* @param sessionSocketRawFDs Anonymous session sockets that are currently open
- * @return In the Zygote process this function will always return null; in blastula processes
- * this function will return a Runnable object representing the new application that is
- * passed up from blastulaMain.
+ * @return In the Zygote process this function will always return null; in unspecialized app
+ * processes this function will return a Runnable object representing the new
+ * application that is passed up from usapMain.
*/
- Runnable fillBlastulaPool(int[] sessionSocketRawFDs) {
- Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Zygote:FillBlastulaPool");
+ Runnable fillUsapPool(int[] sessionSocketRawFDs) {
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Zygote:FillUsapPool");
- int blastulaPoolCount = Zygote.getBlastulaPoolCount();
- int numBlastulasToSpawn = mBlastulaPoolSizeMax - blastulaPoolCount;
+ int usapPoolCount = Zygote.getUsapPoolCount();
+ int numUsapsToSpawn = mUsapPoolSizeMax - usapPoolCount;
- if (blastulaPoolCount < mBlastulaPoolSizeMin
- || numBlastulasToSpawn >= mBlastulaPoolRefillThreshold) {
+ if (usapPoolCount < mUsapPoolSizeMin
+ || numUsapsToSpawn >= mUsapPoolRefillThreshold) {
// Disable some VM functionality and reset some system values
// before forking.
ZygoteHooks.preFork();
Zygote.resetNicePriority();
- while (blastulaPoolCount++ < mBlastulaPoolSizeMax) {
- Runnable caller = Zygote.forkBlastula(mBlastulaPoolSocket, sessionSocketRawFDs);
+ while (usapPoolCount++ < mUsapPoolSizeMax) {
+ Runnable caller = Zygote.forkUsap(mUsapPoolSocket, sessionSocketRawFDs);
if (caller != null) {
return caller;
}
}
- // Re-enable runtime services for the Zygote. Blastula services
- // are re-enabled in specializeBlastula.
+ // Re-enable runtime services for the Zygote. Services for unspecialized app process
+ // are re-enabled in specializeAppProcess.
ZygoteHooks.postForkCommon();
Log.i("zygote",
- "Filled the blastula pool. New blastulas: " + numBlastulasToSpawn);
+ "Filled the USAP pool. New USAPs: " + numUsapsToSpawn);
}
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
@@ -337,23 +337,23 @@
}
/**
- * Empty or fill the blastula pool as dictated by the current and new blastula pool statuses.
+ * Empty or fill the USAP pool as dictated by the current and new USAP pool statuses.
*/
- Runnable setBlastulaPoolStatus(boolean newStatus, LocalSocket sessionSocket) {
- if (!mBlastulaPoolSupported) {
+ Runnable setUsapPoolStatus(boolean newStatus, LocalSocket sessionSocket) {
+ if (!mUsapPoolSupported) {
Log.w(TAG,
- "Attempting to enable a blastula pool for a Zygote that doesn't support it.");
+ "Attempting to enable a USAP pool for a Zygote that doesn't support it.");
return null;
- } else if (mBlastulaPoolEnabled == newStatus) {
+ } else if (mUsapPoolEnabled == newStatus) {
return null;
}
- mBlastulaPoolEnabled = newStatus;
+ mUsapPoolEnabled = newStatus;
if (newStatus) {
- return fillBlastulaPool(new int[]{ sessionSocket.getFileDescriptor().getInt$() });
+ return fillUsapPool(new int[]{ sessionSocket.getFileDescriptor().getInt$() });
} else {
- Zygote.emptyBlastulaPool();
+ Zygote.emptyUsapPool();
return null;
}
}
@@ -371,25 +371,25 @@
peers.add(null);
while (true) {
- fetchBlastulaPoolPolicyPropsWithMinInterval();
+ fetchUsapPoolPolicyPropsWithMinInterval();
- int[] blastulaPipeFDs = null;
+ int[] usapPipeFDs = null;
StructPollfd[] pollFDs = null;
// Allocate enough space for the poll structs, taking into account
- // the state of the blastula pool for this Zygote (could be a
+ // the state of the USAP pool for this Zygote (could be a
// regular Zygote, a WebView Zygote, or an AppZygote).
- if (mBlastulaPoolEnabled) {
- blastulaPipeFDs = Zygote.getBlastulaPipeFDs();
- pollFDs = new StructPollfd[socketFDs.size() + 1 + blastulaPipeFDs.length];
+ if (mUsapPoolEnabled) {
+ usapPipeFDs = Zygote.getUsapPipeFDs();
+ pollFDs = new StructPollfd[socketFDs.size() + 1 + usapPipeFDs.length];
} else {
pollFDs = new StructPollfd[socketFDs.size()];
}
/*
- * For reasons of correctness the blastula pool pipe and event FDs
+ * For reasons of correctness the USAP pool pipe and event FDs
* must be processed before the session and server sockets. This
- * is to ensure that the blastula pool accounting information is
+ * is to ensure that the USAP pool accounting information is
* accurate when handling other requests like API blacklist
* exemptions.
*/
@@ -402,17 +402,17 @@
++pollIndex;
}
- final int blastulaPoolEventFDIndex = pollIndex;
+ final int usapPoolEventFDIndex = pollIndex;
- if (mBlastulaPoolEnabled) {
+ if (mUsapPoolEnabled) {
pollFDs[pollIndex] = new StructPollfd();
- pollFDs[pollIndex].fd = mBlastulaPoolEventFD;
+ pollFDs[pollIndex].fd = mUsapPoolEventFD;
pollFDs[pollIndex].events = (short) POLLIN;
++pollIndex;
- for (int blastulaPipeFD : blastulaPipeFDs) {
+ for (int usapPipeFD : usapPipeFDs) {
FileDescriptor managedFd = new FileDescriptor();
- managedFd.setInt$(blastulaPipeFD);
+ managedFd.setInt$(usapPipeFD);
pollFDs[pollIndex] = new StructPollfd();
pollFDs[pollIndex].fd = managedFd;
@@ -427,7 +427,7 @@
throw new RuntimeException("poll failed", ex);
}
- boolean blastulaPoolFDRead = false;
+ boolean usapPoolFDRead = false;
while (--pollIndex >= 0) {
if ((pollFDs[pollIndex].revents & POLLIN) == 0) {
@@ -441,7 +441,7 @@
peers.add(newPeer);
socketFDs.add(newPeer.getFileDescriptor());
- } else if (pollIndex < blastulaPoolEventFDIndex) {
+ } else if (pollIndex < usapPoolEventFDIndex) {
// Session socket accepted from the Zygote server socket
try {
@@ -502,56 +502,56 @@
mIsForkChild = false;
}
} else {
- // Either the blastula pool event FD or a blastula reporting pipe.
+ // Either the USAP pool event FD or a USAP reporting pipe.
- // If this is the event FD the payload will be the number of blastulas removed.
- // If this is a reporting pipe FD the payload will be the PID of the blastula
+ // If this is the event FD the payload will be the number of USAPs removed.
+ // If this is a reporting pipe FD the payload will be the PID of the USAP
// that was just specialized.
long messagePayload = -1;
try {
- byte[] buffer = new byte[Zygote.BLASTULA_MANAGEMENT_MESSAGE_BYTES];
+ byte[] buffer = new byte[Zygote.USAP_MANAGEMENT_MESSAGE_BYTES];
int readBytes = Os.read(pollFDs[pollIndex].fd, buffer, 0, buffer.length);
- if (readBytes == Zygote.BLASTULA_MANAGEMENT_MESSAGE_BYTES) {
+ if (readBytes == Zygote.USAP_MANAGEMENT_MESSAGE_BYTES) {
DataInputStream inputStream =
new DataInputStream(new ByteArrayInputStream(buffer));
messagePayload = inputStream.readLong();
} else {
- Log.e(TAG, "Incomplete read from blastula management FD of size "
+ Log.e(TAG, "Incomplete read from USAP management FD of size "
+ readBytes);
continue;
}
} catch (Exception ex) {
- if (pollIndex == blastulaPoolEventFDIndex) {
- Log.e(TAG, "Failed to read from blastula pool event FD: "
+ if (pollIndex == usapPoolEventFDIndex) {
+ Log.e(TAG, "Failed to read from USAP pool event FD: "
+ ex.getMessage());
} else {
- Log.e(TAG, "Failed to read from blastula reporting pipe: "
+ Log.e(TAG, "Failed to read from USAP reporting pipe: "
+ ex.getMessage());
}
continue;
}
- if (pollIndex > blastulaPoolEventFDIndex) {
- Zygote.removeBlastulaTableEntry((int) messagePayload);
+ if (pollIndex > usapPoolEventFDIndex) {
+ Zygote.removeUsapTableEntry((int) messagePayload);
}
- blastulaPoolFDRead = true;
+ usapPoolFDRead = true;
}
}
- // Check to see if the blastula pool needs to be refilled.
- if (blastulaPoolFDRead) {
+ // Check to see if the USAP pool needs to be refilled.
+ if (usapPoolFDRead) {
int[] sessionSocketRawFDs =
socketFDs.subList(1, socketFDs.size())
.stream()
.mapToInt(fd -> fd.getInt$())
.toArray();
- final Runnable command = fillBlastulaPool(sessionSocketRawFDs);
+ final Runnable command = fillUsapPool(sessionSocketRawFDs);
if (command != null) {
return command;