Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7fdd022 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Added watchdog monitor for Binder threads availability.

The watchdog will trigger if all binder threads in the system_server
are stuck for a long time (1min) preventing the process from
handling additional IPC requests.

Bug: 19297165
Change-Id: I5909a9c230bf23917feaed53f2b54bd50425bf3c
parent 5929b7b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22491,6 +22491,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[]);
+1 −0
Original line number Diff line number Diff line
@@ -24375,6 +24375,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[]);
+6 −0
Original line number Diff line number Diff line
@@ -186,6 +186,12 @@ public class Binder implements IBinder {
        return iface.asBinder() != iface;
    }

    /**
     * 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.
     */
+7 −1
Original line number Diff line number Diff line
@@ -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";
+1 −2
Original line number Diff line number Diff line
@@ -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;
Loading