From 96d8935a05eb601f87de3ba30b9ee1a6a2ccd8f5 Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Tue, 24 Jan 2023 23:56:57 -0800 Subject: [PATCH] Log the service component name in the service_request_event_reported Bug: 259370123 Test: statsd_testdrive 476 Change-Id: I06e6476a17fa86a3f3dc0445bdb08d4d0abb71ca --- .../java/com/android/server/am/ActiveServices.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 73bb8d7e01728..f0b168dafae14 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -1272,7 +1272,8 @@ public final class ActiveServices { : (wasStartRequested || !r.getConnections().isEmpty() ? SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_HOT : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM), - getShortProcessNameForStats(callingUid, callingProcessName)); + getShortProcessNameForStats(callingUid, callingProcessName), + getShortServiceNameForStats(r)); if (r.startRequested && addToStarting) { boolean first = smap.mStartingBackground.size() == 0; @@ -1311,6 +1312,11 @@ public final class ActiveServices { return processName; } + private @Nullable String getShortServiceNameForStats(@NonNull ServiceRecord r) { + final ComponentName cn = r.getComponentName(); + return cn != null ? cn.getShortClassName() : null; + } + private void stopServiceLocked(ServiceRecord service, boolean enqueueOomAdj) { try { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "stopServiceLocked()"); @@ -3488,7 +3494,8 @@ public final class ActiveServices { : (wasStartRequested || hadConnections ? SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_HOT : SERVICE_REQUEST_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM), - getShortProcessNameForStats(callingUid, callerApp.processName)); + getShortProcessNameForStats(callingUid, callerApp.processName), + getShortServiceNameForStats(s)); if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Bind " + s + " with " + b + ": received=" + b.intent.received