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

Commit 2853f31d authored by Isak Evaldsson's avatar Isak Evaldsson Committed by Snild Dolkow
Browse files

Looper: Add global and per process override for slow message threshold

Adds the log.looper.any.main.slow and log.looper.<PID>.any.slow
sysprops, which allows a global slow dispatch/delivery threshold to be
set for all running main loopers, as well as a threshold for all threads
within the process.

Having a single propery instead of needing to lookup uids for all apps
and then setting a threshold property for each thread makes manual
testing and debugging for slow looper messages easier.

Bug: 326356810
Test: manual - Setprop log.looper.slow.all_processes and observe log
Change-Id: I6fdb8b1ef51eedb6160963bef0e4b17eb2ea5494
parent 2daef7f6
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -322,6 +322,23 @@ public final class Looper {

    @android.ravenwood.annotation.RavenwoodReplace
    private static int getThresholdOverride() {
        // Allow overriding the threshold for all processes' main looper with a system prop.
        // e.g. adb shell 'setprop log.looper.any.main.slow 1 && stop && start'
        if (myLooper() == getMainLooper()) {
            final int globalOverride = SystemProperties.getInt("log.looper.any.main.slow", -1);
            if (globalOverride >= 0) {
                return globalOverride;
            }
        }

        // Allow overriding the threshold for all threads within a process with a system prop.
        // e.g. adb shell 'setprop log.looper.1000.any.slow 1 && stop && start'
        final int processOverride = SystemProperties.getInt("log.looper."
                + Process.myUid() + ".any.slow", -1);
        if (processOverride >= 0) {
            return processOverride;
        }

        return SystemProperties.getInt("log.looper."
                + Process.myUid() + "."
                + Thread.currentThread().getName()