summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2015-04-15 12:35:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-15 12:35:34 +0000
commitcc3c34c9675fdf02da23326b0788e8a587bb399d (patch)
tree966444560560b3c5a0c11a3b79c85fe9b8590dbe
parent017ed840fa4922f1cdec17f8378543a09c4ca9ca (diff)
parentd7fdd0228e6abdbc079f9cf08b780e4222dfe7c5 (diff)
downloadframeworks_base-cc3c34c9675fdf02da23326b0788e8a587bb399d.zip
frameworks_base-cc3c34c9675fdf02da23326b0788e8a587bb399d.tar.gz
frameworks_base-cc3c34c9675fdf02da23326b0788e8a587bb399d.tar.bz2
Merge "Added watchdog monitor for Binder threads availability."
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--core/java/android/os/Binder.java6
-rw-r--r--core/jni/android_util_Binder.cpp8
-rw-r--r--services/core/java/com/android/server/Watchdog.java3
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java10
6 files changed, 26 insertions, 3 deletions
diff --git a/api/current.txt b/api/current.txt
index b307d61..9b47519 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22499,6 +22499,7 @@ package android.os {
public class Binder implements android.os.IBinder {
ctor public Binder();
method public void attachInterface(android.os.IInterface, java.lang.String);
+ method public static final void blockUntilThreadAvailable();
method public static final long clearCallingIdentity();
method public void dump(java.io.FileDescriptor, java.lang.String[]);
method protected void dump(java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
diff --git a/api/system-current.txt b/api/system-current.txt
index 9184d8b..3fd3517 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -24387,6 +24387,7 @@ package android.os {
public class Binder implements android.os.IBinder {
ctor public Binder();
method public void attachInterface(android.os.IInterface, java.lang.String);
+ method public static final void blockUntilThreadAvailable();
method public static final long clearCallingIdentity();
method public void dump(java.io.FileDescriptor, java.lang.String[]);
method protected void dump(java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index b4a4624..b77b82c 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -187,6 +187,12 @@ public class Binder implements IBinder {
}
/**
+ * Call blocks until the number of executing binder threads is less
+ * than the maximum number of binder threads allowed for this process.
+ */
+ public static final native void blockUntilThreadAvailable();
+
+ /**
* Default constructor initializes the object.
*/
public Binder() {
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 5f42c3d..cfbedda 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -807,6 +807,11 @@ static void android_os_Binder_destroy(JNIEnv* env, jobject obj)
}
}
+static void android_os_Binder_blockUntilThreadAvailable(JNIEnv* env, jobject clazz)
+{
+ return IPCThreadState::self()->blockUntilThreadAvailable();
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod gBinderMethods[] = {
@@ -819,7 +824,8 @@ static const JNINativeMethod gBinderMethods[] = {
{ "getThreadStrictModePolicy", "()I", (void*)android_os_Binder_getThreadStrictModePolicy },
{ "flushPendingCommands", "()V", (void*)android_os_Binder_flushPendingCommands },
{ "init", "()V", (void*)android_os_Binder_init },
- { "destroy", "()V", (void*)android_os_Binder_destroy }
+ { "destroy", "()V", (void*)android_os_Binder_destroy },
+ { "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable }
};
const char* const kBinderPathName = "android/os/Binder";
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index 794e1b0..69e61f6 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -46,7 +46,6 @@ import java.util.ArrayList;
/** This class calls its monitor every minute. Killing this process if they don't return **/
public class Watchdog extends Thread {
static final String TAG = "Watchdog";
- static final boolean localLOGV = false || false;
// Set this to true to use debug default values.
static final boolean DB = false;
@@ -73,7 +72,7 @@ public class Watchdog extends Thread {
static Watchdog sWatchdog;
/* This handler will be used to post message back onto the main thread */
- final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<HandlerChecker>();
+ final ArrayList<HandlerChecker> mHandlerCheckers = new ArrayList<>();
final HandlerChecker mMonitorChecker;
ContentResolver mResolver;
ActivityManagerService mActivity;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index b606353..37f0e35 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2179,6 +2179,15 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ 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) {
@@ -2273,6 +2282,7 @@ public final class ActivityManagerService extends ActivityManagerNative
};
Watchdog.getInstance().addMonitor(this);
+ Watchdog.getInstance().addMonitor(new BinderThreadMonitor());
Watchdog.getInstance().addThread(mHandler);
}