summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Olivier Gaillard <gaillard@google.com> 2022-07-01 00:22:30 +0100
committer Olivier Gaillard <gaillard@google.com> 2022-07-01 00:38:36 +0100
commit7bcfa69d497d19894adc40dbd6a4fd73214cfea1 (patch)
tree799308b0d966745bdedcd074f2638a8c916eb685
parent8c1602bf8afa932f988f551f5f4086f7db57c6fc (diff)
Add the timeout duration to the watchdog message.
The timeout will varies depending on the handler checker and can also be controlled by flags. Test: Existing unit tests still pass. Change-Id: I25dcbb58e087b4d5c2ff5e99d5da603d8b8e2b9e
-rw-r--r--services/core/java/com/android/server/Watchdog.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index 76c897aac051..7cf790ad5b54 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -230,10 +230,10 @@ public class Watchdog implements Dumpable {
private final String mName;
private final ArrayList<Monitor> mMonitors = new ArrayList<Monitor>();
private final ArrayList<Monitor> mMonitorQueue = new ArrayList<Monitor>();
- private long mWaitMax;
+ private long mWaitMaxMillis;
private boolean mCompleted;
private Monitor mCurrentMonitor;
- private long mStartTime;
+ private long mStartTimeMillis;
private int mPauseCount;
HandlerChecker(Handler handler, String name) {
@@ -254,7 +254,7 @@ public class Watchdog implements Dumpable {
* @param handlerCheckerTimeoutMillis the timeout to use for this run
*/
public void scheduleCheckLocked(long handlerCheckerTimeoutMillis) {
- mWaitMax = handlerCheckerTimeoutMillis;
+ mWaitMaxMillis = handlerCheckerTimeoutMillis;
if (mCompleted) {
// Safe to update monitors in queue, Handler is not in the middle of work
mMonitors.addAll(mMonitorQueue);
@@ -279,7 +279,7 @@ public class Watchdog implements Dumpable {
mCompleted = false;
mCurrentMonitor = null;
- mStartTime = SystemClock.uptimeMillis();
+ mStartTimeMillis = SystemClock.uptimeMillis();
mHandler.postAtFrontOfQueue(this);
}
@@ -287,10 +287,10 @@ public class Watchdog implements Dumpable {
if (mCompleted) {
return COMPLETED;
} else {
- long latency = SystemClock.uptimeMillis() - mStartTime;
- if (latency < mWaitMax/2) {
+ long latency = SystemClock.uptimeMillis() - mStartTimeMillis;
+ if (latency < mWaitMaxMillis / 2) {
return WAITING;
- } else if (latency < mWaitMax) {
+ } else if (latency < mWaitMaxMillis) {
return WAITED_HALF;
}
}
@@ -306,14 +306,17 @@ public class Watchdog implements Dumpable {
}
String describeBlockedStateLocked() {
- Thread thread = getThread();
- String threadIdentifier = thread.getName() + ", tid=" + thread.getId();
+ final String prefix;
if (mCurrentMonitor == null) {
- return "Blocked in handler on " + mName + " (" + threadIdentifier + ")";
+ prefix = "Blocked in handler on ";
} else {
- return "Blocked in monitor " + mCurrentMonitor.getClass().getName()
- + " on " + mName + " (" + threadIdentifier + ")";
+ prefix = "Blocked in monitor " + mCurrentMonitor.getClass().getName();
}
+ Thread thread = getThread();
+ String threadIdentifier = thread.getName() + ", tid=" + thread.getId();
+ long latencySeconds = (SystemClock.uptimeMillis() - mStartTimeMillis) / 1000;
+ return prefix + " on " + mName + " (" + threadIdentifier + ")"
+ + " for " + latencySeconds + "s";
}
@Override