Enable binder txn tracing more broadly

Previously, binder txns were only traced for txns from sysui/launcher
to system_server.

aosp/I57857443495475b1d2efa82cbcb448af5d37a79a and
aosp/I01d520afa8e26eabb97318192151b707b002c28b enabled aidl tracing
if aidl#gen_trace or aidl#generate_traces respectively is true.

Guarded tracing on the availability of txn names instead

Test: Manual
Bug: 161393989
Change-Id: Iffc4bb534d239c07d2e4d43ab43a9ed76abe7496
Merged-In: Iffc4bb534d239c07d2e4d43ab43a9ed76abe7496
This commit is contained in:
Zim
2022-09-13 15:12:41 +01:00
parent 8314a3e51b
commit 1b71f6b3d0

View File

@@ -1262,8 +1262,15 @@ public class Binder implements IBinder {
// Log any exceptions as warnings, don't silently suppress them.
// If the call was {@link IBinder#FLAG_ONEWAY} then these exceptions
// disappear into the ether.
final boolean tracingEnabled = Trace.isTagEnabled(Trace.TRACE_TAG_AIDL) &&
(Binder.isStackTrackingEnabled() || Binder.isTracingEnabled(callingUid));
final boolean tagEnabled = Trace.isTagEnabled(Trace.TRACE_TAG_AIDL);
final String transactionTraceName;
if (tagEnabled) {
transactionTraceName = getTransactionTraceName(code);
} else {
transactionTraceName = null;
}
final boolean tracingEnabled = tagEnabled && transactionTraceName != null;
try {
final BinderCallHeavyHitterWatcher heavyHitterWatcher = sHeavyHitterWatcher;
if (heavyHitterWatcher != null) {
@@ -1271,7 +1278,7 @@ public class Binder implements IBinder {
heavyHitterWatcher.onTransaction(callingUid, getClass(), code);
}
if (tracingEnabled) {
Trace.traceBegin(Trace.TRACE_TAG_AIDL, getTransactionTraceName(code));
Trace.traceBegin(Trace.TRACE_TAG_AIDL, transactionTraceName);
}
if ((flags & FLAG_COLLECT_NOTED_APP_OPS) != 0) {