Loading services/core/java/com/android/server/am/DropboxRateLimiter.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,9 +64,10 @@ public class DropboxRateLimiter { } if (now - errRecord.getStartTime() > RATE_LIMIT_BUFFER_DURATION) { final int errCount = recentlyDroppedCount(errRecord); errRecord.setStartTime(now); errRecord.setCount(1); return new RateLimitResult(false, recentlyDroppedCount(errRecord)); return new RateLimitResult(false, errCount); } errRecord.incrementCount(); Loading services/tests/servicestests/src/com/android/server/am/DropboxRateLimiterTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,16 @@ public class DropboxRateLimiterTest { mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); assertEquals(2, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); // After 11 seconds the rate limiting buffer will be cleared and rate limiting will stop. mClock.setOffsetMillis(11000); // The first call after rate limiting stops will still return the number of dropped events. assertEquals(2, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); // The next call should show that the dropped event counter was reset. assertEquals(0, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); } private static class TestClock implements DropboxRateLimiter.Clock { Loading Loading
services/core/java/com/android/server/am/DropboxRateLimiter.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,9 +64,10 @@ public class DropboxRateLimiter { } if (now - errRecord.getStartTime() > RATE_LIMIT_BUFFER_DURATION) { final int errCount = recentlyDroppedCount(errRecord); errRecord.setStartTime(now); errRecord.setCount(1); return new RateLimitResult(false, recentlyDroppedCount(errRecord)); return new RateLimitResult(false, errCount); } errRecord.incrementCount(); Loading
services/tests/servicestests/src/com/android/server/am/DropboxRateLimiterTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,16 @@ public class DropboxRateLimiterTest { mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); assertEquals(2, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); // After 11 seconds the rate limiting buffer will be cleared and rate limiting will stop. mClock.setOffsetMillis(11000); // The first call after rate limiting stops will still return the number of dropped events. assertEquals(2, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); // The next call should show that the dropped event counter was reset. assertEquals(0, mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated()); } private static class TestClock implements DropboxRateLimiter.Clock { Loading