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
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index a529ac6..712d328 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -177,12 +177,15 @@
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 @@
SystemProperties.getInt("log.looper."
+ Process.myUid() + "."
+ Thread.currentThread().getName()
- + ".slow", 0);
+ + ".slow", -1);
me.mSlowDeliveryDetected = false;