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

Commit 9a900f66 authored by Achim Thesmann's avatar Achim Thesmann Committed by Android (Google) Code Review
Browse files

Merge "Use same logic to check BAL permission" into main

parents 76b58777 56730cd6
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -853,8 +853,7 @@ public class BackgroundActivityStartController {
        }

        // don't abort if the callingUid has START_ACTIVITIES_FROM_BACKGROUND permission
        if (ActivityTaskManagerService.checkPermission(START_ACTIVITIES_FROM_BACKGROUND,
                callingPid, callingUid) == PERMISSION_GRANTED) {
        if (hasBalPermission(callingUid, callingPid)) {
            return new BalVerdict(BAL_ALLOW_PERMISSION,
                    /*background*/ true,
                    "START_ACTIVITIES_FROM_BACKGROUND permission granted");
@@ -919,9 +918,7 @@ public class BackgroundActivityStartController {
    BalVerdict checkBackgroundActivityStartAllowedBySender(BalState state) {

        if (state.isPendingIntentBalAllowedByPermission()
                && ActivityManager.checkComponentPermission(
                android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND,
                state.mRealCallingUid, NO_PROCESS_UID, true) == PackageManager.PERMISSION_GRANTED) {
                && hasBalPermission(state.mRealCallingUid, state.mRealCallingPid)) {
            return new BalVerdict(BAL_ALLOW_PERMISSION,
                    /*background*/ false,
                    "realCallingUid has BAL permission.");
@@ -980,6 +977,11 @@ public class BackgroundActivityStartController {
        return BalVerdict.BLOCK;
    }

    @VisibleForTesting boolean hasBalPermission(int uid, int pid) {
        return ActivityTaskManagerService.checkPermission(START_ACTIVITIES_FROM_BACKGROUND,
                pid, uid) == PERMISSION_GRANTED;
    }

    /**
     * Check if the app allows BAL.
     * <p>