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

Commit 781385d8 authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Android (Google) Code Review
Browse files

Merge "Adding Perfetto trace tags for FGS start/stop" into main

parents 24a9de23 e4dc87e5
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.app.ActivityManager.ForegroundServiceApiType;
import android.app.ForegroundServiceDelegationOptions;
import android.content.ComponentName;
import android.content.pm.ServiceInfo;
import android.os.Trace;
import android.util.ArrayMap;
import android.util.IntArray;
import android.util.LongArray;
@@ -134,6 +135,11 @@ public class ForegroundServiceTypeLoggerModule {
     * call of the right type will also be associated and logged
     */
    public void logForegroundServiceStart(int uid, int pid, ServiceRecord record) {
        if (record.getComponentName() != null) {
            final String traceTag = record.getComponentName().flattenToString() + ":" + uid;
            Trace.asyncTraceForTrackBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, traceTag,
                    "foregroundService", record.foregroundServiceType);
        }
        // initialize the UID stack
        UidState uidState = mUids.get(uid);
        if (uidState == null) {
@@ -205,6 +211,11 @@ public class ForegroundServiceTypeLoggerModule {
        // we need to log all the API end events and remove the start events
        // then we remove the FGS from the various stacks
        // and also clean up the start calls stack by UID
        if (record.getComponentName() != null) {
            final String traceTag = record.getComponentName().flattenToString() + ":" + uid;
            Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                    traceTag, record.hashCode());
        }
        final IntArray apiTypes = convertFgsTypeToApiTypes(record.foregroundServiceType);
        final UidState uidState = mUids.get(uid);
        if (apiTypes.size() == 0) {