diff options
| author | Hui Yu <huiyu@google.com> | 2020-02-25 12:03:26 -0800 |
|---|---|---|
| committer | Hui Yu <huiyu@google.com> | 2020-02-26 14:59:10 +0000 |
| commit | 4cda1e515cb2c985fda1569b3dca8a67ca70dd35 (patch) | |
| tree | b87e7681e9d7f0f97e4b5f1ee4f3843a451126fa | |
| parent | c46bf0786c7d1200739717f4c1271a9d04936e59 (diff) | |
Pass START_ACTIVITIES_FROM_BACKGROUND permission to instrumentation
test.
So the instrumentation can have the same permssion as app and it can
skip the FGS background start while-in-use restriction.
Also reuse the ProcessRecord.mAllowBackgroundActivityStartsTokens flag.
Bug: 136219221
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java
Change-Id: I7d8708945ffe79b83825f8edb688078706c46770
(cherry picked from commit 5a5daafbcab55d051b0e241eb8adfacde2155e36)
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 211da0a3e9dc..f408fe749eb4 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -4869,6 +4869,19 @@ public final class ActiveServices { return true; } + if (r.app != null) { + ActiveInstrumentation instr = r.app.getActiveInstrumentation(); + if (instr != null && instr.mHasBackgroundActivityStartsPermission) { + return true; + } + } + + final boolean hasAllowBackgroundActivityStartsToken = r.app != null + ? !r.app.mAllowBackgroundActivityStartsTokens.isEmpty() : false; + if (hasAllowBackgroundActivityStartsToken) { + return true; + } + if (mAm.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid) == PERMISSION_GRANTED) { return true; |
