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

Commit 84efefd6 authored by Chris Wailes's avatar Chris Wailes
Browse files

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
parent b203ac2f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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();
        }
+19 −2
Original line number Diff line number Diff line
@@ -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;