summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Wailes <chriswailes@google.com> 2019-03-11 16:20:02 -0700
committer Chris Wailes <chriswailes@google.com> 2019-03-12 11:19:42 -0700
commit84efefd666fa116fb1d3c77ecd0bbb617194f2ab (patch)
treef308fe685cb9c38a426cf4d591ee2a892ddd8af7
parentb203ac2fe89d3eded7f381c4a57d8212d44ec120 (diff)
Fixes initialization bug in USAP pool properties.
This patch fixes an initialization order bug in the USAP pool policy management code. Previously, bad values were used when initializing the USAP pool when it was enabled on device boot. This patch ensures that the policy system properties have been checked before the pool is initialized. Test: Boot with USAP pool enabled Change-Id: I29d91abd511bc35c7a70a3a56668c7ee2290864b
-rw-r--r--core/java/android/os/ZygoteProcess.java5
-rw-r--r--core/java/com/android/internal/os/ZygoteServer.java21
2 files changed, 23 insertions, 3 deletions
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
index 3f985f356f93..ff551d46fb2a 100644
--- a/core/java/android/os/ZygoteProcess.java
+++ b/core/java/android/os/ZygoteProcess.java
@@ -678,12 +678,15 @@ public class ZygoteProcess {
return origVal != mUsapPoolEnabled;
}
+ private boolean mIsFirstPropCheck = true;
private long mLastPropCheckTimestamp = 0;
private boolean fetchUsapPoolEnabledPropWithMinInterval() {
final long currentTimestamp = SystemClock.elapsedRealtime();
- if (currentTimestamp - mLastPropCheckTimestamp >= Zygote.PROPERTY_CHECK_INTERVAL) {
+ if (mIsFirstPropCheck
+ || (currentTimestamp - mLastPropCheckTimestamp >= Zygote.PROPERTY_CHECK_INTERVAL)) {
+ mIsFirstPropCheck = false;
mLastPropCheckTimestamp = currentTimestamp;
return fetchUsapPoolEnabledProp();
}
diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java
index 65953172818e..4aff912104f5 100644
--- a/core/java/com/android/internal/os/ZygoteServer.java
+++ b/core/java/com/android/internal/os/ZygoteServer.java
@@ -277,17 +277,31 @@ class ZygoteServer {
Integer.parseInt(usapPoolRefillThresholdPropString),
mUsapPoolSizeMax);
}
+
+ // Sanity check
+
+ if (mUsapPoolSizeMin >= mUsapPoolSizeMax) {
+ Log.w(TAG, "The max size of the USAP pool must be greater than the minimum size."
+ + " Restoring default values.");
+
+ mUsapPoolSizeMax = Integer.parseInt(USAP_POOL_SIZE_MAX_DEFAULT);
+ mUsapPoolSizeMin = Integer.parseInt(USAP_POOL_SIZE_MIN_DEFAULT);
+ mUsapPoolRefillThreshold = mUsapPoolSizeMax / 2;
+ }
}
}
+ private boolean mIsFirstPropertyCheck = true;
private long mLastPropCheckTimestamp = 0;
private void fetchUsapPoolPolicyPropsWithMinInterval() {
final long currentTimestamp = SystemClock.elapsedRealtime();
- if (currentTimestamp - mLastPropCheckTimestamp >= Zygote.PROPERTY_CHECK_INTERVAL) {
- fetchUsapPoolPolicyProps();
+ if (mIsFirstPropertyCheck
+ || (currentTimestamp - mLastPropCheckTimestamp >= Zygote.PROPERTY_CHECK_INTERVAL)) {
+ mIsFirstPropertyCheck = false;
mLastPropCheckTimestamp = currentTimestamp;
+ fetchUsapPoolPolicyProps();
}
}
@@ -304,6 +318,9 @@ class ZygoteServer {
Runnable fillUsapPool(int[] sessionSocketRawFDs) {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Zygote:FillUsapPool");
+ // Ensure that the pool properties have been fetched.
+ fetchUsapPoolPolicyPropsWithMinInterval();
+
int usapPoolCount = Zygote.getUsapPoolCount();
int numUsapsToSpawn = mUsapPoolSizeMax - usapPoolCount;