diff options
| author | 2023-06-05 17:12:07 +0000 | |
|---|---|---|
| committer | 2023-06-05 17:12:07 +0000 | |
| commit | 14a3f763d98ea75568dac745ec4fc3d7cb908c23 (patch) | |
| tree | 2e4023d8b2c7247758c0ef2085ecf823c9feae9f | |
| parent | afbc4be9b0744abf73c66209dbf4bcf1f8ec4f0d (diff) | |
| parent | b5ff652f2abeaf65b555cc6296466f7268572e24 (diff) | |
Merge "Follow-up to Ifb322f9603aad841b4947038574d5d1a42d3dc10" into udc-dev am: 100eaf664f am: b5ff652f2a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23521301
Change-Id: I9ed932250486afca199733df1a54a067e635813d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 7ede4614232f..6f205636b476 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -2156,9 +2156,7 @@ public final class ActiveServices { } } - final boolean fgsTypeChangingFromShortFgs = r.isForeground && isOldTypeShortFgs; - - if (fgsTypeChangingFromShortFgs) { + if (r.isForeground && isOldTypeShortFgs) { // If we get here, that means startForeground(SHORT_SERVICE) is called again // on a SHORT_SERVICE FGS. @@ -2211,9 +2209,7 @@ public final class ActiveServices { // "if (r.mAllowStartForeground == REASON_DENIED...)" block below. } } - } - - if (!fgsTypeChangingFromShortFgs && r.mStartForegroundCount == 0) { + } else if (r.mStartForegroundCount == 0) { /* If the service was started with startService(), not startForegroundService(), and if startForeground() isn't called within @@ -2244,7 +2240,7 @@ public final class ActiveServices { r.mLoggedInfoAllowStartForeground = false; } } - } else if (!fgsTypeChangingFromShortFgs && r.mStartForegroundCount >= 1) { + } else if (r.mStartForegroundCount >= 1) { // We get here if startForeground() is called multiple times // on the same service after it's created, regardless of whether // stopForeground() has been called or not. @@ -7436,14 +7432,10 @@ public final class ActiveServices { r.mAllowWhileInUsePermissionInFgs = true; } - // Either (or both) mAllowWhileInUsePermissionInFgs or mAllowStartForeground is - // newly allowed? - boolean newlyAllowed = false; if (!r.mAllowWhileInUsePermissionInFgs || (r.mAllowStartForeground == REASON_DENIED)) { @ReasonCode final int allowWhileInUse = shouldAllowFgsWhileInUsePermissionLocked( - callingPackage, callingPid, callingUid, r.app, backgroundStartPrivileges, - isBindService); + callingPackage, callingPid, callingUid, r.app, backgroundStartPrivileges); // We store them to compare the old and new while-in-use logics to each other. // (They're not used for any other purposes.) if (!r.mAllowWhileInUsePermissionInFgs) { @@ -7477,7 +7469,7 @@ public final class ActiveServices { } final @ReasonCode int allowWhileInUse = shouldAllowFgsWhileInUsePermissionLocked( callingPackage, callingPid, callingUid, null /* targetProcess */, - BackgroundStartPrivileges.NONE, false); + BackgroundStartPrivileges.NONE); @ReasonCode int allowStartFgs = shouldAllowFgsStartForegroundNoBindingCheckLocked( allowWhileInUse, callingPid, callingUid, callingPackage, null /* targetService */, BackgroundStartPrivileges.NONE); @@ -7501,19 +7493,15 @@ public final class ActiveServices { */ private @ReasonCode int shouldAllowFgsWhileInUsePermissionLocked(String callingPackage, int callingPid, int callingUid, @Nullable ProcessRecord targetProcess, - BackgroundStartPrivileges backgroundStartPrivileges, boolean isBindService) { + BackgroundStartPrivileges backgroundStartPrivileges) { int ret = REASON_DENIED; - final boolean forStartForeground = !isBindService; - - if (forStartForeground) { - final int uidState = mAm.getUidStateLocked(callingUid); - if (ret == REASON_DENIED) { - // Allow FGS while-in-use if the caller's process state is PROCESS_STATE_PERSISTENT, - // PROCESS_STATE_PERSISTENT_UI or PROCESS_STATE_TOP. - if (uidState <= PROCESS_STATE_TOP) { - ret = getReasonCodeFromProcState(uidState); - } + final int uidState = mAm.getUidStateLocked(callingUid); + if (ret == REASON_DENIED) { + // Allow FGS while-in-use if the caller's process state is PROCESS_STATE_PERSISTENT, + // PROCESS_STATE_PERSISTENT_UI or PROCESS_STATE_TOP. + if (uidState <= PROCESS_STATE_TOP) { + ret = getReasonCodeFromProcState(uidState); } } @@ -7734,7 +7722,7 @@ public final class ActiveServices { shouldAllowFgsWhileInUsePermissionLocked( clientPackageName, clientPid, clientUid, null /* targetProcess */, - BackgroundStartPrivileges.NONE, false); + BackgroundStartPrivileges.NONE); final @ReasonCode int allowStartFgs = shouldAllowFgsStartForegroundNoBindingCheckLocked( allowWhileInUse2, @@ -8163,7 +8151,7 @@ public final class ActiveServices { String callingPackage) { return shouldAllowFgsWhileInUsePermissionLocked(callingPackage, callingPid, callingUid, /* targetProcess */ null, - BackgroundStartPrivileges.NONE, false) + BackgroundStartPrivileges.NONE) != REASON_DENIED; } @@ -8171,7 +8159,7 @@ public final class ActiveServices { String callingPackage, @Nullable ProcessRecord targetProcess, @NonNull BackgroundStartPrivileges backgroundStartPrivileges) { return shouldAllowFgsWhileInUsePermissionLocked(callingPackage, callingPid, callingUid, - targetProcess, backgroundStartPrivileges, false) != REASON_DENIED; + targetProcess, backgroundStartPrivileges) != REASON_DENIED; } /** |