diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowProcessController.java | 27 |
2 files changed, 22 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index fcb32a1677b1..e476ca908b5d 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -5373,7 +5373,7 @@ public final class ActiveServices { for (int i = mAm.mProcessList.mLruProcesses.size() - 1; i >= 0; i--) { final ProcessRecord pr = mAm.mProcessList.mLruProcesses.get(i); if (pr.uid == callingUid) { - if (pr.getWindowProcessController().areBackgroundActivityStartsAllowed()) { + if (pr.getWindowProcessController().areBackgroundFgsStartsAllowed()) { ret = FGS_FEATURE_ALLOWED_BY_ACTIVITY_STARTER; break; } diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index 389f428a4138..66b6616ea28f 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -519,13 +519,21 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } } - public boolean areBackgroundActivityStartsAllowed() { + /** + * Is this WindowProcessController in the state of allowing background FGS start? + */ + public boolean areBackgroundFgsStartsAllowed() { synchronized (mAtm.mGlobalLock) { - return areBackgroundActivityStartsAllowed(mAtm.getBalAppSwitchesAllowed()); + return areBackgroundActivityStartsAllowed(mAtm.getBalAppSwitchesAllowed(), true); } } boolean areBackgroundActivityStartsAllowed(boolean appSwitchAllowed) { + return areBackgroundActivityStartsAllowed(appSwitchAllowed, false); + } + + boolean areBackgroundActivityStartsAllowed(boolean appSwitchAllowed, + boolean isCheckingForFgsStart) { // If app switching is not allowed, we ignore all the start activity grace period // exception so apps cannot start itself in onPause() after pressing home button. if (appSwitchAllowed) { @@ -579,7 +587,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return true; } // allow if the flag was explicitly set - if (isBackgroundStartAllowedByToken()) { + if (isBackgroundStartAllowedByToken(isCheckingForFgsStart)) { if (DEBUG_ACTIVITY_STARTS) { Slog.d(TAG, "[WindowProcessController(" + mPid + ")] Activity start allowed: process allowed by token"); @@ -590,13 +598,20 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } /** - * If there are no tokens, we don't allow *by token*. If there are tokens, we ask the callback - * if the start is allowed for these tokens, otherwise if there is no callback we allow. + * If there are no tokens, we don't allow *by token*. If there are tokens and + * isCheckingForFgsStart is false, we ask the callback if the start is allowed for these tokens, + * otherwise if there is no callback we allow. */ - private boolean isBackgroundStartAllowedByToken() { + private boolean isBackgroundStartAllowedByToken(boolean isCheckingForFgsStart) { if (mBackgroundActivityStartTokens.isEmpty()) { return false; } + + if (isCheckingForFgsStart) { + /// The checking is for BG-FGS-start. + return true; + } + if (mBackgroundActivityStartCallback == null) { // We have tokens but no callback to decide => allow return true; |