Addressed deferred CL feedback comments.
This CL addresses several bits of feedback from previous CLs:
* ZygoteState.mABIList => ZygoteState.mAbiList
* Adding appropriate whitespace
* Finalizing variables where appropriate
* TEMP_RETRY_FAILURE around write
* Zygote.getSystemProperty => Zygote.getConfigurationProperty
Test: m
Test: Treehugger
Change-Id: I5ae4c8dfc336c7511bee375a80966abb1ead275e
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
index ff551d4..b6bc95d 100644
--- a/core/java/android/os/ZygoteProcess.java
+++ b/core/java/android/os/ZygoteProcess.java
@@ -147,7 +147,7 @@
final DataInputStream mZygoteInputStream;
final BufferedWriter mZygoteOutputWriter;
- private final List<String> mABIList;
+ private final List<String> mAbiList;
private boolean mClosed;
@@ -162,7 +162,7 @@
this.mZygoteSessionSocket = zygoteSessionSocket;
this.mZygoteInputStream = zygoteInputStream;
this.mZygoteOutputWriter = zygoteOutputWriter;
- this.mABIList = abiList;
+ this.mAbiList = abiList;
}
/**
@@ -215,7 +215,7 @@
}
boolean matches(String abi) {
- return mABIList.contains(abi);
+ return mAbiList.contains(abi);
}
public void close() {
@@ -338,7 +338,7 @@
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo,
- abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/false,
+ abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/ false,
packageName, packagesForUid, sandboxId,
useUsapPool, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
@@ -374,7 +374,7 @@
byte[] bytes = new byte[numBytes];
inputStream.readFully(bytes);
- String rawList = new String(bytes, StandardCharsets.US_ASCII);
+ final String rawList = new String(bytes, StandardCharsets.US_ASCII);
return Arrays.asList(rawList.split(","));
}
@@ -660,13 +660,13 @@
boolean origVal = mUsapPoolEnabled;
final String propertyString =
- Zygote.getSystemProperty(
+ Zygote.getConfigurationProperty(
DeviceConfig.RuntimeNative.USAP_POOL_ENABLED,
USAP_POOL_ENABLED_DEFAULT);
if (!propertyString.isEmpty()) {
mUsapPoolEnabled =
- Zygote.getSystemPropertyBoolean(
+ Zygote.getConfigurationPropertyBoolean(
DeviceConfig.RuntimeNative.USAP_POOL_ENABLED,
Boolean.parseBoolean(USAP_POOL_ENABLED_DEFAULT));
}
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 70d8b45..3655748 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -408,7 +408,7 @@
* TODO (chriswailes): Cache the system property location in native code and then write a JNI
* function to fetch it.
*/
- public static String getSystemProperty(String propertyName, String defaultValue) {
+ public static String getConfigurationProperty(String propertyName, String defaultValue) {
return SystemProperties.get(
String.join(".",
"persist.device_config",
@@ -433,8 +433,10 @@
*
* TODO (chriswailes): Cache the system property location in native code and then write a JNI
* function to fetch it.
+ * TODO (chriswailes): Move into ZygoteConfig.java once the necessary CL lands (go/ag/6580627)
*/
- public static boolean getSystemPropertyBoolean(String propertyName, Boolean defaultValue) {
+ public static boolean getConfigurationPropertyBoolean(
+ String propertyName, Boolean defaultValue) {
return SystemProperties.getBoolean(
String.join(".",
"persist.device_config",
diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java
index 4aff912..7abfd85 100644
--- a/core/java/com/android/internal/os/ZygoteServer.java
+++ b/core/java/com/android/internal/os/ZygoteServer.java
@@ -243,7 +243,7 @@
private void fetchUsapPoolPolicyProps() {
if (mUsapPoolSupported) {
final String usapPoolSizeMaxPropString =
- Zygote.getSystemProperty(
+ Zygote.getConfigurationProperty(
DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MAX,
USAP_POOL_SIZE_MAX_DEFAULT);
@@ -255,7 +255,7 @@
}
final String usapPoolSizeMinPropString =
- Zygote.getSystemProperty(
+ Zygote.getConfigurationProperty(
DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MIN,
USAP_POOL_SIZE_MIN_DEFAULT);
@@ -267,7 +267,7 @@
}
final String usapPoolRefillThresholdPropString =
- Zygote.getSystemProperty(
+ Zygote.getConfigurationProperty(
DeviceConfig.RuntimeNative.USAP_POOL_REFILL_THRESHOLD,
Integer.toString(mUsapPoolSizeMax / 2));
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index c6f62ca..009a6ca 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -352,7 +352,7 @@
}
if (usaps_removed > 0) {
- if (write(gUsapPoolEventFD, &usaps_removed, sizeof(usaps_removed)) == -1) {
+ if (TEMP_FAILURE_RETRY(write(gUsapPoolEventFD, &usaps_removed, sizeof(usaps_removed))) == -1) {
// If this write fails something went terribly wrong. We will now kill
// the zygote and let the system bring it back up.
async_safe_format_log(ANDROID_LOG_ERROR, LOG_TAG,