summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiim Sammul <siims@google.com>2022-08-26 11:54:17 +0100
committerIris Chang <iris.chang@mediatek.com>2022-09-01 15:55:30 +0000
commitd21ca1f86c9ccd88fdf35f689ff26cc77b2bb01a (patch)
tree795e02b0c5196ef081945ad167788a2418e63d4d
parentbff944d05cd47d2b3b713565d3f00d512840d282 (diff)
downloadbase-d21ca1f86c9ccd88fdf35f689ff26cc77b2bb01a.tar.gz
Add the ability to reset dropbox rate limiter with a shell command.
Cherry picked from internal master Bug: 242671309 Test: atest ErrorsTest Change-Id: I87b8c6e49c809d94a036ccac5d4381dba691e727 Merged-In: I87b8c6e49c809d94a036ccac5d4381dba691e727 (cherry picked from commit dd6df2939d86a2163c6318aa7ff51c348ded8d65)
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java7
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerShellCommand.java7
-rw-r--r--services/core/java/com/android/server/am/DropboxRateLimiter.java11
3 files changed, 25 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a78c64b6538d..18c55070193c 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -17786,6 +17786,13 @@ public class ActivityManagerService extends IActivityManager.Stub
}
/**
+ * Reset the dropbox rate limiter
+ */
+ void resetDropboxRateLimiter() {
+ mDropboxRateLimiter.reset();
+ }
+
+ /**
* Kill processes for the user with id userId and that depend on the package named packageName
*/
@Override
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 2c2579f9e504..fb4271fccbff 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -348,6 +348,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
return runSetBgAbusiveUids(pw);
case "list-bg-exemptions-config":
return runListBgExemptionsConfig(pw);
+ case "reset-dropbox-rate-limiter":
+ return runResetDropboxRateLimiter();
default:
return handleDefaultCommands(cmd);
}
@@ -3363,6 +3365,11 @@ final class ActivityManagerShellCommand extends ShellCommand {
return 0;
}
+ int runResetDropboxRateLimiter() throws RemoteException {
+ mInternal.resetDropboxRateLimiter();
+ return 0;
+ }
+
private Resources getResources(PrintWriter pw) throws RemoteException {
// system resources does not contain all the device configuration, construct it manually.
Configuration config = mInterface.getConfiguration();
diff --git a/services/core/java/com/android/server/am/DropboxRateLimiter.java b/services/core/java/com/android/server/am/DropboxRateLimiter.java
index baf062d28457..6087f76687bf 100644
--- a/services/core/java/com/android/server/am/DropboxRateLimiter.java
+++ b/services/core/java/com/android/server/am/DropboxRateLimiter.java
@@ -19,11 +19,13 @@ package com.android.server.am;
import android.os.SystemClock;
import android.text.format.DateUtils;
import android.util.ArrayMap;
+import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
/** Rate limiter for adding errors into dropbox. */
public class DropboxRateLimiter {
+ private static final String TAG = "DropboxRateLimiter";
// After RATE_LIMIT_ALLOWED_ENTRIES have been collected (for a single breakdown of
// process/eventType) further entries will be rejected until RATE_LIMIT_BUFFER_DURATION has
// elapsed, after which the current count for this breakdown will be reset.
@@ -105,6 +107,15 @@ public class DropboxRateLimiter {
mLastMapCleanUp = now;
}
+ /** Resets the rate limiter memory. */
+ void reset() {
+ synchronized (mErrorClusterRecords) {
+ mErrorClusterRecords.clear();
+ }
+ mLastMapCleanUp = 0L;
+ Slog.i(TAG, "Rate limiter reset.");
+ }
+
String errorKey(String eventType, String processName) {
return eventType + processName;
}