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

Commit 331d8dc9 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Move proxy debug info dumping back to Java.

This had to be called from native because serialization
was done from native, but now that serialization is in Java
we can move this back to a more logical place.

Also, this allows us to dump the per-UID proxy counts in
this situation again.

Bug: 109888955
Test: sailfish builds, proxy debug info shown on hitting limits
Change-Id: I4e06b3f93e30ed1c7868ec9e018709a7e796e441
parent ba75cf11
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -351,15 +351,12 @@ public final class BinderProxy implements IBinder {
     *
     * @hide
     */
    private static void dumpProxyDebugInfo() {
    public static void dumpProxyDebugInfo() {
        if (Build.IS_DEBUGGABLE) {
            synchronized (sProxyMap) {
                sProxyMap.dumpProxyInterfaceCounts();
                sProxyMap.dumpPerUidProxyCounts();
            }
            // Note that we don't call dumpPerUidProxyCounts(); this is because this
            // method may be called as part of the uid limit being hit, and calling
            // back into the UID tracking code would cause us to try to acquire a mutex
            // that is held during that callback.
        }
    }

+0 −13
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ static struct binderproxy_offsets_t
    jclass mClass;
    jmethodID mGetInstance;
    jmethodID mSendDeathNotice;
    jmethodID mDumpProxyDebugInfo;

    // Object state.
    jfieldID mNativeData;  // Field holds native pointer to BinderProxyNativeData.
@@ -994,16 +993,6 @@ static void android_os_BinderInternal_handleGc(JNIEnv* env, jobject clazz)
static void android_os_BinderInternal_proxyLimitcallback(int uid)
{
    JNIEnv *env = AndroidRuntime::getJNIEnv();
    {
        env->CallStaticObjectMethod(gBinderProxyOffsets.mClass,
                                    gBinderProxyOffsets.mDumpProxyDebugInfo);
    }
    if (env->ExceptionCheck()) {
        ScopedLocalRef<jthrowable> excep(env, env->ExceptionOccurred());
        report_exception(env, excep.get(),
            "*** Uncaught exception in dumpProxyDebugInfo");
    }

    env->CallStaticVoidMethod(gBinderInternalOffsets.mClass,
                              gBinderInternalOffsets.mProxyLimitCallback,
                              uid);
@@ -1390,8 +1379,6 @@ static int int_register_android_os_BinderProxy(JNIEnv* env)
            "(JJ)Landroid/os/BinderProxy;");
    gBinderProxyOffsets.mSendDeathNotice = GetStaticMethodIDOrDie(env, clazz, "sendDeathNotice",
            "(Landroid/os/IBinder$DeathRecipient;)V");
    gBinderProxyOffsets.mDumpProxyDebugInfo = GetStaticMethodIDOrDie(env, clazz, "dumpProxyDebugInfo",
            "()V");
    gBinderProxyOffsets.mNativeData = GetFieldIDOrDie(env, clazz, "mNativeData", "J");

    clazz = FindClassOrDie(env, "java/lang/Class");
+1 −0
Original line number Diff line number Diff line
@@ -11578,6 +11578,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        public void onLimitReached(int uid) {
                            Slog.wtf(TAG, "Uid " + uid + " sent too many Binders to uid "
                                    + Process.myUid());
                            BinderProxy.dumpProxyDebugInfo();
                            if (uid == Process.SYSTEM_UID) {
                                Slog.i(TAG, "Skipping kill (uid is SYSTEM)");
                            } else {