Moved SystemServer binder thread monitor from AMS to Monitor class.
Since to it applies to more than just the ActivityManagerService.
Bug: 19297165
Change-Id: I3affd50aaf8a49589ca48b845d6d31e4a44efb8f
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index 69e61f6..772a15c 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -190,6 +190,17 @@
}
}
+ /** Monitor for checking the availability of binder threads. The monitor will block until
+ * there is a binder thread available to process in coming IPCs to make sure other processes
+ * can still communicate with the service.
+ */
+ private static final class BinderThreadMonitor implements Watchdog.Monitor {
+ @Override
+ public void monitor() {
+ Binder.blockUntilThreadAvailable();
+ }
+ }
+
public interface Monitor {
void monitor();
}
@@ -227,6 +238,9 @@
// And the display thread.
mHandlerCheckers.add(new HandlerChecker(DisplayThread.getHandler(),
"display thread", DEFAULT_TIMEOUT));
+
+ // Initialize monitor for Binder threads.
+ addMonitor(new BinderThreadMonitor());
}
public void init(Context context, ActivityManagerService activity) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 37f0e35..b606353 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2179,15 +2179,6 @@
}
}
- public static final class BinderThreadMonitor implements Watchdog.Monitor {
- /** This method will block until there is a binder thread available to process
- * in coming IPCs to make sure other processes can still communicate with the service.
- */
- @Override
- public void monitor() {
- Binder.blockUntilThreadAvailable();
- }
- }
// Note: This method is invoked on the main thread but may need to attach various
// handlers to other threads. So take care to be explicit about the looper.
public ActivityManagerService(Context systemContext) {
@@ -2282,7 +2273,6 @@
};
Watchdog.getInstance().addMonitor(this);
- Watchdog.getInstance().addMonitor(new BinderThreadMonitor());
Watchdog.getInstance().addThread(mHandler);
}