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

Commit e4dc87e5 authored by Kunal's avatar Kunal
Browse files

Adding Perfetto trace tags for FGS start/stop

Bug: 295545575
Test: build
Change-Id: Ib732c37ee6859ad3345c003c689e49b8c616004a
parent 29e125bc
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) {