Loading services/core/java/com/android/server/job/controllers/QuotaController.java +4 −2 Original line number Diff line number Diff line Loading @@ -2291,8 +2291,10 @@ public final class QuotaController extends StateController { mAllowedTimeIntoQuotaMs = mAllowedTimePerPeriodMs - mQuotaBufferMs; changed = true; } long newQuotaBufferMs = Math.max(0, Math.min(5 * MINUTE_IN_MILLIS, IN_QUOTA_BUFFER_MS)); // Make sure quota buffer is non-negative, not greater than allowed time per period, // and no more than 5 minutes. long newQuotaBufferMs = Math.max(0, Math.min(mAllowedTimePerPeriodMs, Math.min(5 * MINUTE_IN_MILLIS, IN_QUOTA_BUFFER_MS))); if (mQuotaBufferMs != newQuotaBufferMs) { mQuotaBufferMs = newQuotaBufferMs; mAllowedTimeIntoQuotaMs = mAllowedTimePerPeriodMs - mQuotaBufferMs; Loading services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -1925,6 +1925,16 @@ public class QuotaControllerTest { assertEquals(1, mQuotaController.getBucketMaxSessionCounts()[RARE_INDEX]); assertEquals(0, mQuotaController.getTimingSessionCoalescingDurationMs()); // Invalid configurations. // In_QUOTA_BUFFER should never be greater than ALLOWED_TIME_PER_PERIOD mQcConstants.ALLOWED_TIME_PER_PERIOD_MS = 2 * MINUTE_IN_MILLIS; mQcConstants.IN_QUOTA_BUFFER_MS = 5 * MINUTE_IN_MILLIS; mQcConstants.updateConstants(); assertTrue(mQuotaController.getInQuotaBufferMs() <= mQuotaController.getAllowedTimePerPeriodMs()); // Test larger than a day. Controller should cap at one day. mQcConstants.ALLOWED_TIME_PER_PERIOD_MS = 25 * HOUR_IN_MILLIS; mQcConstants.IN_QUOTA_BUFFER_MS = 25 * HOUR_IN_MILLIS; Loading Loading
services/core/java/com/android/server/job/controllers/QuotaController.java +4 −2 Original line number Diff line number Diff line Loading @@ -2291,8 +2291,10 @@ public final class QuotaController extends StateController { mAllowedTimeIntoQuotaMs = mAllowedTimePerPeriodMs - mQuotaBufferMs; changed = true; } long newQuotaBufferMs = Math.max(0, Math.min(5 * MINUTE_IN_MILLIS, IN_QUOTA_BUFFER_MS)); // Make sure quota buffer is non-negative, not greater than allowed time per period, // and no more than 5 minutes. long newQuotaBufferMs = Math.max(0, Math.min(mAllowedTimePerPeriodMs, Math.min(5 * MINUTE_IN_MILLIS, IN_QUOTA_BUFFER_MS))); if (mQuotaBufferMs != newQuotaBufferMs) { mQuotaBufferMs = newQuotaBufferMs; mAllowedTimeIntoQuotaMs = mAllowedTimePerPeriodMs - mQuotaBufferMs; Loading
services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -1925,6 +1925,16 @@ public class QuotaControllerTest { assertEquals(1, mQuotaController.getBucketMaxSessionCounts()[RARE_INDEX]); assertEquals(0, mQuotaController.getTimingSessionCoalescingDurationMs()); // Invalid configurations. // In_QUOTA_BUFFER should never be greater than ALLOWED_TIME_PER_PERIOD mQcConstants.ALLOWED_TIME_PER_PERIOD_MS = 2 * MINUTE_IN_MILLIS; mQcConstants.IN_QUOTA_BUFFER_MS = 5 * MINUTE_IN_MILLIS; mQcConstants.updateConstants(); assertTrue(mQuotaController.getInQuotaBufferMs() <= mQuotaController.getAllowedTimePerPeriodMs()); // Test larger than a day. Controller should cap at one day. mQcConstants.ALLOWED_TIME_PER_PERIOD_MS = 25 * HOUR_IN_MILLIS; mQcConstants.IN_QUOTA_BUFFER_MS = 25 * HOUR_IN_MILLIS; Loading