Skip to content

Commit

Permalink
Merge "Add more details to broadcastIntent trace events." into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudheer Shanka authored and Android (Google) Code Review committed Jun 10, 2024
2 parents 45ba476 + 564922c commit 35753dd
Showing 1 changed file with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15274,15 +15274,50 @@ final int broadcastIntentLocked(ProcessRecord callerApp, String callerPackage,
BackgroundStartPrivileges backgroundStartPrivileges,
@Nullable int[] broadcastAllowList,
@Nullable BiFunction<Integer, Bundle, Bundle> filterExtrasForReceiver) {
final int cookie = BroadcastQueue.traceBegin("broadcastIntentLockedTraced");
final int res = broadcastIntentLockedTraced(callerApp, callerPackage, callerFeatureId,
intent, resolvedType, resultToApp, resultTo, resultCode, resultData, resultExtras,
requiredPermissions, excludedPermissions, excludedPackages, appOp,
BroadcastOptions.fromBundleNullable(bOptions), ordered, sticky,
callingPid, callingUid, realCallingUid, realCallingPid, userId,
backgroundStartPrivileges, broadcastAllowList, filterExtrasForReceiver);
BroadcastQueue.traceEnd(cookie);
return res;
final int cookie = traceBroadcastIntentBegin(intent, resultTo, ordered, sticky,
callingUid, realCallingUid, userId);
try {
final int res = broadcastIntentLockedTraced(callerApp, callerPackage, callerFeatureId,
intent, resolvedType, resultToApp, resultTo, resultCode, resultData,
resultExtras, requiredPermissions, excludedPermissions, excludedPackages,
appOp, BroadcastOptions.fromBundleNullable(bOptions), ordered, sticky,
callingPid, callingUid, realCallingUid, realCallingPid, userId,
backgroundStartPrivileges, broadcastAllowList, filterExtrasForReceiver);
return res;
} finally {
traceBroadcastIntentEnd(cookie);
}
}

private static int traceBroadcastIntentBegin(Intent intent, IIntentReceiver resultTo,
boolean ordered, boolean sticky, int callingUid, int realCallingUid, int userId) {
if (!Flags.traceReceiverRegistration()) {
return BroadcastQueue.traceBegin("broadcastIntentLockedTraced");
}
if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
final StringBuilder sb = new StringBuilder("broadcastIntent: ");
sb.append(callingUid); sb.append('/');
final String action = intent.getAction();
sb.append(action == null ? null : action); sb.append('/');
sb.append("0x"); sb.append(Integer.toHexString(intent.getFlags())); sb.append('/');
sb.append(ordered ? "O" : "_");
sb.append(sticky ? "S" : "_");
sb.append(resultTo != null ? "C" : "_");
sb.append('/');
sb.append('u'); sb.append(userId);
if (callingUid != realCallingUid) {
sb.append('/');
sb.append("sender="); sb.append(realCallingUid);
}
return BroadcastQueue.traceBegin(sb.toString());
}
return 0;
}

private static void traceBroadcastIntentEnd(int cookie) {
if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
BroadcastQueue.traceEnd(cookie);
}
}

@GuardedBy("this")
Expand Down

0 comments on commit 35753dd

Please sign in to comment.