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

Commit 175fc99c authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Do not synchronize on IPCs and callbacks

This can lead to ANRs and deadlocks, given that we might wait for an
unreasonable amount of time.

Test: atest
Test: manual
Fixes: 148634425
Change-Id: Iad7f47b18613d2aa3a5590d4c7c9556bbf545735
parent 9dfa86c5
Loading
Loading
Loading
Loading
+26 −18
Original line number Diff line number Diff line
@@ -61,12 +61,15 @@ public class DejankUtils {
                        || !isMainThread() || sTemporarilyIgnoreStrictMode) {
                    return null;
                }
            }

            try {
                String description = binder.getInterfaceDescriptor();
                synchronized (sLock) {
                    if (sWhitelistedFrameworkClasses.contains(description)) {
                        return null;
                    }
                }
            } catch (RemoteException e) {
                e.printStackTrace();
            }
@@ -74,7 +77,6 @@ public class DejankUtils {
            StrictMode.noteSlowCall("IPC detected on critical path: " + sBlockingIpcs.peek());
            return null;
        }
        }

        @Override
        public Object onTransactStarted(IBinder binder, int transactionCode) {
@@ -126,9 +128,11 @@ public class DejankUtils {
        if (STRICT_MODE_ENABLED && sBlockingIpcs.empty()) {
            synchronized (sLock) {
                sBlockingIpcs.push("detectBlockingIpcs");
            }
            try {
                runnable.run();
            } finally {
                synchronized (sLock) {
                    sBlockingIpcs.pop();
                }
            }
@@ -177,9 +181,11 @@ public class DejankUtils {
        if (STRICT_MODE_ENABLED && !sTemporarilyIgnoreStrictMode) {
            synchronized (sLock) {
                sTemporarilyIgnoreStrictMode = true;
            }
            try {
                runnable.run();
            } finally {
                synchronized (sLock) {
                    sTemporarilyIgnoreStrictMode = false;
                }
            }
@@ -196,14 +202,16 @@ public class DejankUtils {
        if (STRICT_MODE_ENABLED && !sTemporarilyIgnoreStrictMode) {
            synchronized (sLock) {
                sTemporarilyIgnoreStrictMode = true;
            }
            final T val;
            try {
                val = supplier.get();
            } finally {
                synchronized (sLock) {
                    sTemporarilyIgnoreStrictMode = false;
                }
                return val;
            }
            return val;
        } else {
            return supplier.get();
        }