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

Commit 618e0577 authored by Hui Yu's avatar Hui Yu
Browse files

Log the timed out event for SHORT_SERVICE type FGS.

Into ForegroundServiceStateChanged atom.

Bug: 275631423
Test: statsd_testdrive 60
Change-Id: I743477e54bd342980adafdf14e8194678b84dd16
parent f9a77b96
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import static com.android.internal.messages.nano.SystemMessageProto.SystemMessag
import static com.android.internal.util.FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__DENIED;
import static com.android.internal.util.FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER;
import static com.android.internal.util.FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT;
import static com.android.internal.util.FrameworkStatsLog.FOREGROUND_SERVICE_STATE_CHANGED__STATE__TIMED_OUT;
import static com.android.internal.util.FrameworkStatsLog.SERVICE_REQUEST_EVENT_REPORTED;
import static com.android.internal.util.FrameworkStatsLog.SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL;
import static com.android.internal.util.FrameworkStatsLog.SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_STOPPED;
@@ -3240,6 +3241,12 @@ public final class ActiveServices {
                return;
            }
            Slog.e(TAG_SERVICE, "Short FGS timed out: " + sr);
            final long now = SystemClock.uptimeMillis();
            logFGSStateChangeLocked(sr,
                    FOREGROUND_SERVICE_STATE_CHANGED__STATE__TIMED_OUT,
                    now > sr.mFgsEnterTime ? (int) (now - sr.mFgsEnterTime) : 0,
                    FGS_STOP_REASON_UNKNOWN,
                    FGS_TYPE_POLICY_CHECK_UNKNOWN);
            try {
                sr.app.getThread().scheduleTimeoutService(sr, sr.getShortFgsInfo().getStartId());
            } catch (RemoteException e) {
@@ -7897,7 +7904,8 @@ public final class ActiveServices {
        boolean allowWhileInUsePermissionInFgs;
        @PowerExemptionManager.ReasonCode int fgsStartReasonCode;
        if (state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER
                || state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT) {
                || state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__EXIT
                || state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__TIMED_OUT) {
            allowWhileInUsePermissionInFgs = r.mAllowWhileInUsePermissionInFgsAtEntering;
            fgsStartReasonCode = r.mAllowStartForegroundAtEntering;
        } else {
@@ -7931,9 +7939,9 @@ public final class ActiveServices {
                r.mFgsDelegation != null ? r.mFgsDelegation.mOptions.mClientUid : INVALID_UID,
                r.mFgsDelegation != null ? r.mFgsDelegation.mOptions.mDelegationService
                        : ForegroundServiceDelegationOptions.DELEGATION_SERVICE_DEFAULT,
                0,
                null,
                null);
                0 /* api_sate */,
                null /* api_type */,
                null /* api_timestamp */);

        int event = 0;
        if (state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__ENTER) {
@@ -7942,6 +7950,8 @@ public final class ActiveServices {
            event = EventLogTags.AM_FOREGROUND_SERVICE_STOP;
        } else if (state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__DENIED) {
            event = EventLogTags.AM_FOREGROUND_SERVICE_DENIED;
        } else if (state == FOREGROUND_SERVICE_STATE_CHANGED__STATE__TIMED_OUT) {
            event = EventLogTags.AM_FOREGROUND_SERVICE_TIMED_OUT;
        }else {
            // Unknown event.
            return;
+2 −1
Original line number Diff line number Diff line
@@ -121,10 +121,11 @@ option java_package com.android.server.am
# Similarly, tags below are used by UserManagerService
30091 um_user_visibility_changed (userId|1|5),(visible|1)

# Foreground service start/stop events.
# Foreground service start/stop/denied/timed_out events.
30100 am_foreground_service_start (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3),(fgsType|1)
30101 am_foreground_service_denied (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3),(fgsType|1)
30102 am_foreground_service_stop (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3),(fgsType|1)
30103 am_foreground_service_timed_out (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3),(fgsType|1)

# Intent Sender redirect for UserHandle.USER_CURRENT
30110 am_intent_sender_redirect_user (userId|1|5)