Update the looper "slow message log"

Now you can set `setprop log.looper.1000.main.slow 0` to print all
handler messages. (previously 1 was the minimum allowed value.)

The above example will enable logging for the "main" thread on
UID 1000 (SYSTEM_UID).

Bug: n/a
Test: manual test with `setprop log.looper.1000.main.slow 0; adb shell stop; adb shell start`
and looking at logcat

Test: another manual test, make sure, without the setprop, no logs are printed.

Change-Id: I6172b211b6f01f2fb73a5c57cd93bdb219dca4f4
This commit is contained in:
Makoto Onuki
2022-12-08 16:19:09 -08:00
parent 8f733beefc
commit 5ba5545833

View File

@@ -177,12 +177,15 @@ public final class Looper {
final long traceTag = me.mTraceTag;
long slowDispatchThresholdMs = me.mSlowDispatchThresholdMs;
long slowDeliveryThresholdMs = me.mSlowDeliveryThresholdMs;
if (thresholdOverride > 0) {
final boolean hasOverride = thresholdOverride >= 0;
if (hasOverride) {
slowDispatchThresholdMs = thresholdOverride;
slowDeliveryThresholdMs = thresholdOverride;
}
final boolean logSlowDelivery = (slowDeliveryThresholdMs > 0) && (msg.when > 0);
final boolean logSlowDispatch = (slowDispatchThresholdMs > 0);
final boolean logSlowDelivery = (slowDeliveryThresholdMs > 0 || hasOverride)
&& (msg.when > 0);
final boolean logSlowDispatch = (slowDispatchThresholdMs > 0 || hasOverride);
final boolean needStartTime = logSlowDelivery || logSlowDispatch;
final boolean needEndTime = logSlowDispatch;
@@ -283,7 +286,7 @@ public final class Looper {
SystemProperties.getInt("log.looper."
+ Process.myUid() + "."
+ Thread.currentThread().getName()
+ ".slow", 0);
+ ".slow", -1);
me.mSlowDeliveryDetected = false;