From bee73eb39b9e74e8cf710a75b939c374c53c084f Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Tue, 10 Mar 2026 16:37:50 +0100 Subject: [PATCH] perf(binder): skip interception for system transaction codes AIDL methods use codes 1..0x00ffffff. System transactions like PING_TRANSACTION (0x5f4e4750) fall above that range. Intercepting pings forces a full JNI round-trip to Java and back, adding enough latency for timing detectors to flag the ratio (3.85x vs 3.0x threshold). Early-return for codes above LAST_CALL_TRANSACTION eliminates this overhead while preserving all AIDL interception. --- app/src/main/cpp/binder_interceptor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/cpp/binder_interceptor.cpp b/app/src/main/cpp/binder_interceptor.cpp index b602732..7845782 100644 --- a/app/src/main/cpp/binder_interceptor.cpp +++ b/app/src/main/cpp/binder_interceptor.cpp @@ -358,6 +358,12 @@ void inspectAndRewriteTransaction(binder_transaction_data *txn_data) { if (txn_data->data_size > kMaxInterceptableDataSize) return; + // AIDL methods use codes in [FIRST_CALL_TRANSACTION, LAST_CALL_TRANSACTION] (1..0x00ffffff). + // System transactions (PING, INTERFACE, DUMP, SHELL_COMMAND) use codes above that range. + // Skip those — intercepting a ping adds measurable latency that timing detectors flag. + if (txn_data->code > 0x00ffffffu && txn_data->code != intercept::kBackdoorCode) + return; + bool hijack = false; ThreadTransactionInfo info;