Add basic inversion lock detection to DPMS.
For now enable it on ENG builds only.
(I'll change the condition in master so I'll get WTFs from qt-release devices
too.)
This will detect calling into DPMS with the following locks held:
APP_OPS
POWER
USER
PACKAGES
STORAGE
WINDOW
ACTIVITY
DPMS
On marlin-eng pi-dev, each guard() takes ~25us.
LockGuard.guard(): count=7246, total=175.1ms, avg=0.024ms
Used the following command to ensure all locks are replaced.
$ grep synchronized /android/pi-dev/frameworks/base/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | sed -e 's/ *//' | uniq
Bug: 74553426
Test: Manual test with an intentional lock inversion.
Change-Id: Id59d562d7c275b6ea127a211284496f5d64f9f93
diff --git a/services/core/java/com/android/server/ThreadPriorityBooster.java b/services/core/java/com/android/server/ThreadPriorityBooster.java
index cc9ac0d..53e8ce4 100644
--- a/services/core/java/com/android/server/ThreadPriorityBooster.java
+++ b/services/core/java/com/android/server/ThreadPriorityBooster.java
@@ -25,6 +25,8 @@
*/
public class ThreadPriorityBooster {
+ private static final boolean ENABLE_LOCK_GUARD = false;
+
private volatile int mBoostToPriority;
private final int mLockGuardIndex;
@@ -50,7 +52,7 @@
}
}
state.regionCounter++;
- if (LockGuard.ENABLED) {
+ if (ENABLE_LOCK_GUARD) {
LockGuard.guard(mLockGuardIndex);
}
}