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

Commit 149611da authored by Varun Shah's avatar Varun Shah
Browse files

Remove dependency on gate_fgs_timeout_anr_behavior flag.

Now that the enable_fgs_timeout_crash_behavior flag is completely rolled
out, remove any dependencies on the stop-gap flag we had in place. If we
need to rollback the crashing behavior in the future, we can simply
disable the crash flag since that behavior is decoupled from the timeout
callback flag.

Bug: 330399444
Test: atest CtsFgsTimeoutTestCases
Change-Id: Ifd64d11493d60ec4841e13163caa9e08e03e0a89
parent 37d905d0
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -2452,11 +2452,9 @@ public final class ActiveServices {
                                            + " foreground service type "
                                            + ServiceInfo.foregroundServiceTypeToLabel(
                                                    foregroundServiceType);
                                    // Only throw an exception if the new ANR behavior
                                    // ("do nothing") is not gated or the new crashing logic gate
                                    // Only throw an exception if the new crashing logic gate
                                    // is enabled; otherwise, reset the limit temporarily.
                                    if (!android.app.Flags.gateFgsTimeoutAnrBehavior()
                                            || android.app.Flags.enableFgsTimeoutCrashBehavior()) {
                                    if (android.app.Flags.enableFgsTimeoutCrashBehavior()) {
                                        throw new ForegroundServiceStartNotAllowedException(
                                                    exceptionMsg);
                                    } else {
@@ -3956,21 +3954,12 @@ public final class ActiveServices {
                // stop the service, decrement the number of parallel running services here.
                fgsTypeInfo.decNumParallelServices();
            }
        }

            final String reason = "A foreground service of type "
                    + ServiceInfo.foregroundServiceTypeToLabel(fgsType)
                    + " did not stop within its timeout: " + sr.getComponentName();

        if (android.app.Flags.gateFgsTimeoutAnrBehavior()
                || !android.app.Flags.enableFgsTimeoutCrashBehavior()) {
            // Log a WTF instead of crashing the app while the new behavior is gated.
            Slog.wtf(TAG, reason);
            return;
        }
            if (android.app.Flags.enableFgsTimeoutCrashBehavior()) {
                // Crash the app
            synchronized (mAm) {
                Slog.e(TAG_SERVICE, "FGS Crashed: " + sr);
                traceInstant("FGS Crash: ", sr);
                if (sr.app != null) {
@@ -3980,6 +3969,9 @@ public final class ActiveServices {
                            ForegroundServiceDidNotStopInTimeException
                                    .createExtrasForService(sr.getComponentName()));
                }
            } else {
                // Log a WTF instead of crashing the app while the new behavior is gated.
                Slog.wtf(TAG, reason);
            }
        }
    }