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

Commit 09304aea authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Automerger Merge Worker
Browse files

Merge "FGS stop log bug fix" into udc-qpr-dev am: b13733aa

parents d0025113 b13733aa
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2501,12 +2501,12 @@ public final class ActiveServices {
                        FGS_STOP_REASON_STOP_FOREGROUND,
                        FGS_TYPE_POLICY_CHECK_UNKNOWN);

                // foregroundServiceType is used in logFGSStateChangeLocked(), so we can't clear it
                // earlier.
                r.foregroundServiceType = 0;
                synchronized (mFGSLogger) {
                    mFGSLogger.logForegroundServiceStop(r.appInfo.uid, r);
                }
                // foregroundServiceType is used in logFGSStateChangeLocked(), so we can't clear it
                // earlier.
                r.foregroundServiceType = 0;
                r.mFgsNotificationWasDeferred = false;
                signalForegroundServiceObserversLocked(r);
                resetFgsRestrictionLocked(r);
+22 −13
Original line number Diff line number Diff line
@@ -141,6 +141,10 @@ public class ForegroundServiceTypeLoggerModule {
        // grab the appropriate types
        final IntArray apiTypes =
                convertFgsTypeToApiTypes(record.foregroundServiceType);
        if (apiTypes.size() == 0) {
            Slog.w(TAG, "Foreground service start for UID: "
                    + uid + " does not have any types");
        }
        // now we need to iterate through the types
        // and insert the new record as needed
        final IntArray apiTypesFound = new IntArray();
@@ -201,6 +205,9 @@ public class ForegroundServiceTypeLoggerModule {
        // and also clean up the start calls stack by UID
        final IntArray apiTypes = convertFgsTypeToApiTypes(record.foregroundServiceType);
        final UidState uidState = mUids.get(uid);
        if (apiTypes.size() == 0) {
            Slog.w(TAG, "FGS stop call for: " + uid + " has no types!");
        }
        if (uidState == null) {
            Slog.w(TAG, "FGS stop call being logged with no start call for UID for UID "
                    + uid
@@ -460,17 +467,18 @@ public class ForegroundServiceTypeLoggerModule {
    public void logFgsApiEvent(ServiceRecord r, int fgsState,
            @FgsApiState int apiState,
            @ForegroundServiceApiType int apiType, long timestamp) {
        long apiDurationBeforeFgsStart = r.createRealTime - timestamp;
        long apiDurationAfterFgsEnd = timestamp - r.mFgsExitTime;
        long apiDurationBeforeFgsStart = 0;
        long apiDurationAfterFgsEnd = 0;
        UidState uidState = mUids.get(r.appInfo.uid);
        if (uidState != null) {
        if (uidState == null) {
            return;
        }
        if (uidState.mFirstFgsTimeStamp.contains(apiType)) {
            apiDurationBeforeFgsStart = uidState.mFirstFgsTimeStamp.get(apiType) - timestamp;
        }
        if (uidState.mLastFgsTimeStamp.contains(apiType)) {
            apiDurationAfterFgsEnd = timestamp - uidState.mLastFgsTimeStamp.get(apiType);
        }
        }
        final int[] apiTypes = new int[1];
        apiTypes[0] = apiType;
        final long[] timeStamps = new long[1];
@@ -525,11 +533,12 @@ public class ForegroundServiceTypeLoggerModule {
            @ForegroundServiceApiType int apiType, long timestamp) {
        long apiDurationAfterFgsEnd = 0;
        UidState uidState = mUids.get(uid);
        if (uidState != null) {
        if (uidState == null) {
            return;
        }
        if (uidState.mLastFgsTimeStamp.contains(apiType)) {
            apiDurationAfterFgsEnd = timestamp - uidState.mLastFgsTimeStamp.get(apiType);
        }
        }
        final int[] apiTypes = new int[1];
        apiTypes[0] = apiType;
        final long[] timeStamps = new long[1];