diff options
| author | 2023-12-26 18:20:52 +0000 | |
|---|---|---|
| committer | 2023-12-26 18:20:55 +0000 | |
| commit | 9f27842a53b745205848f64df9670fd411b9fd4c (patch) | |
| tree | d72f8781ffd59cd333b1d878e8fd6797b4c9c6c1 | |
| parent | 06ab29012337ca7fba90a830e8582c16c205db2f (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 96b1650d9575..02f4485d5b40 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -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; |