From c7dc87088e381777f5889fddb6cc3821d3a4fb2d Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Thu, 13 Aug 2020 11:02:38 -0700 Subject: [PATCH] Revert part of previous change. allowBgActivityStartsOnServiceStart() should be called after it is certain that the service start is allowed. Bug: 157473819 Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java Change-Id: Ifcde7f18ea07e9cece84134a48848f84aa6db4ca --- .../core/java/com/android/server/am/ActiveServices.java | 8 +++----- 1 file changed, 3 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 23e9d1b552d58..6328cb60cf739 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -493,11 +493,6 @@ public final class ActiveServices { } ServiceRecord r = res.record; - - if (allowBackgroundActivityStarts) { - r.allowBgActivityStartsOnServiceStart(); - } - setFgsRestrictionLocked(callingPackage, callingPid, callingUid, service, r, allowBackgroundActivityStarts); @@ -710,6 +705,9 @@ public final class ActiveServices { "Not potential delay (user " + r.userId + " not started): " + r); } } + if (allowBackgroundActivityStarts) { + r.allowBgActivityStartsOnServiceStart(); + } ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting); return cmp; }