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

Commit 9f27842a authored by Jing Ji's avatar Jing Ji
Browse files

Move the boot_completed FGS check

..after resetting the fgRequired flag to fix the
ForegroundServiceDidNotStartInTimeException issue
for the FGS start failure cases.

Bug: 317561300
Change-Id: Ic4c85e1209e244c84c3036c310ed2a1254fd2d04
Test: atest CtsAppTestCases
parent 06ab2901
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -2118,11 +2118,6 @@ public final class ActiveServices {
                // anyway, so we just remove the SHORT_SERVICE type.
                foregroundServiceType &= ~FOREGROUND_SERVICE_TYPE_SHORT_SERVICE;
            }
            if (!shouldAllowBootCompletedStart(r, foregroundServiceType)) {
                throw new ForegroundServiceStartNotAllowedException("FGS type "
                        + ServiceInfo.foregroundServiceTypeToLabel(foregroundServiceType)
                        + " not allowed to start from BOOT_COMPLETED!");
            }

            boolean alreadyStartedOp = false;
            boolean stopProcStatsOp = false;
@@ -2137,6 +2132,12 @@ public final class ActiveServices {
                mServiceFGAnrTimer.cancel(r);
            }

            if (!shouldAllowBootCompletedStart(r, foregroundServiceType)) {
                throw new ForegroundServiceStartNotAllowedException("FGS type "
                        + ServiceInfo.foregroundServiceTypeToLabel(foregroundServiceType)
                        + " not allowed to start from BOOT_COMPLETED!");
            }

            final ProcessServiceRecord psr = r.app.mServices;
            try {
                boolean ignoreForeground = false;