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

Commit dec9be5f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Rate limit calls to AM.getProcessesInErrorState" into main

parents 7477c179 b40a9a47
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -233,6 +233,10 @@ public class ActivityManager {
    private static final RateLimitingCache<List<RunningAppProcessInfo>> mRunningProcessesCache =
            new RateLimitingCache<>(10, 4);

    /** Rate-Limiting Cache that allows no more than 200 calls to the service per second. */
    private static final RateLimitingCache<List<ProcessErrorStateInfo>> mErrorProcessesCache =
            new RateLimitingCache<>(10, 2);

    /**
     * Map of callbacks that have registered for {@link UidFrozenStateChanged} events.
     * Will be called when a Uid has become frozen or unfrozen.
@@ -3685,6 +3689,16 @@ public class ActivityManager {
     * specified.
     */
    public List<ProcessErrorStateInfo> getProcessesInErrorState() {
        if (Flags.rateLimitGetProcessesInErrorState()) {
            return mErrorProcessesCache.get(() -> {
                return getProcessesInErrorStateInternal();
            });
        } else {
            return getProcessesInErrorStateInternal();
        }
    }

    private List<ProcessErrorStateInfo> getProcessesInErrorStateInternal() {
        try {
            return getService().getProcessesInErrorState();
        } catch (RemoteException e) {
+11 −0
Original line number Diff line number Diff line
@@ -93,3 +93,14 @@ flag {
     }
}

flag {
     namespace: "backstage_power"
     name: "rate_limit_get_processes_in_error_state"
     description: "Rate limit calls to getProcessesInErrorState using a cache"
     is_fixed_read_only: true
     bug: "361146083"
     metadata {
         purpose: PURPOSE_BUGFIX
     }
}