Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cda1e51 authored by Hui Yu's avatar Hui Yu
Browse files

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 5a5daafb)
parent c46bf078
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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;