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

Commit d5c2d5d7 authored by Chris Wailes's avatar Chris Wailes Committed by android-build-merger
Browse files

Make the USAP Pool refill delay configurable.

am: eabbf872

Change-Id: Ie07333bd97ba8cbd92744d68e17bbd2a84fe77a1
parents 16d1a78e eabbf872
Loading
Loading
Loading
Loading
+17 −7
Original line number Original line Diff line number Diff line
@@ -66,11 +66,8 @@ class ZygoteServer {
    /** The default value used for the USAP_POOL_SIZE_MIN device property */
    /** The default value used for the USAP_POOL_SIZE_MIN device property */
    private static final String USAP_POOL_SIZE_MIN_DEFAULT = "1";
    private static final String USAP_POOL_SIZE_MIN_DEFAULT = "1";


    /**
    /** The default value used for the USAP_REFILL_DELAY_MS device property */
     * Number of milliseconds to delay before refilling the pool if it hasn't reached its
    private static final String USAP_POOL_REFILL_DELAY_MS_DEFAULT = "3000";
     * minimum value.
     */
    private static final int USAP_REFILL_DELAY_MS = 3000;


    /** The "not a timestamp" value for the refill delay timestamp mechanism. */
    /** The "not a timestamp" value for the refill delay timestamp mechanism. */
    private static final int INVALID_TIMESTAMP = -1;
    private static final int INVALID_TIMESTAMP = -1;
@@ -140,6 +137,12 @@ class ZygoteServer {
     */
     */
    private int mUsapPoolRefillThreshold = 0;
    private int mUsapPoolRefillThreshold = 0;


    /**
     * Number of milliseconds to delay before refilling the pool if it hasn't reached its
     * minimum value.
     */
    private int mUsapPoolRefillDelayMs = -1;

    private enum UsapPoolRefillAction {
    private enum UsapPoolRefillAction {
        DELAYED,
        DELAYED,
        IMMEDIATE,
        IMMEDIATE,
@@ -282,6 +285,13 @@ class ZygoteServer {
                        mUsapPoolSizeMax);
                        mUsapPoolSizeMax);
            }
            }


            final String usapPoolRefillDelayMsPropString = Zygote.getConfigurationProperty(
                    ZygoteConfig.USAP_POOL_REFILL_DELAY_MS, USAP_POOL_REFILL_DELAY_MS_DEFAULT);

            if (!usapPoolRefillDelayMsPropString.isEmpty()) {
                mUsapPoolRefillDelayMs = Integer.parseInt(usapPoolRefillDelayMsPropString);
            }

            // Sanity check
            // Sanity check
            if (mUsapPoolSizeMin >= mUsapPoolSizeMax) {
            if (mUsapPoolSizeMin >= mUsapPoolSizeMax) {
                Log.w(TAG, "The max size of the USAP pool must be greater than the minimum size."
                Log.w(TAG, "The max size of the USAP pool must be greater than the minimum size."
@@ -469,13 +479,13 @@ class ZygoteServer {
                int elapsedTimeMs =
                int elapsedTimeMs =
                        (int) (System.currentTimeMillis() - usapPoolRefillTriggerTimestamp);
                        (int) (System.currentTimeMillis() - usapPoolRefillTriggerTimestamp);


                if (elapsedTimeMs >= USAP_REFILL_DELAY_MS) {
                if (elapsedTimeMs >= mUsapPoolRefillDelayMs) {
                    // Normalize the poll timeout value when the time between one poll event and the
                    // Normalize the poll timeout value when the time between one poll event and the
                    // next pushes us over the delay value.  This prevents poll receiving a 0
                    // next pushes us over the delay value.  This prevents poll receiving a 0
                    // timeout value, which would result in it returning immediately.
                    // timeout value, which would result in it returning immediately.
                    pollTimeoutMs = -1;
                    pollTimeoutMs = -1;
                } else {
                } else {
                    pollTimeoutMs = USAP_REFILL_DELAY_MS - elapsedTimeMs;
                    pollTimeoutMs = mUsapPoolRefillDelayMs - elapsedTimeMs;
                }
                }
            }
            }