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

Commit 00a2c9ff authored by Hui Yu's avatar Hui Yu Committed by Automerger Merge Worker
Browse files

Merge "Make sure callingPackage belongs to callingUid when checking BG-FGS...

Merge "Make sure callingPackage belongs to callingUid when checking BG-FGS restrictions." into tm-dev am: c872b772 am: 05c61f5e am: 5aa4d3c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18214570



Change-Id: I6fee45a9b0eb8f647b44f3ff624a356240a124a3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 39bfb6de 5aa4d3c1
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -6475,7 +6475,7 @@ public final class ActiveServices {
            }
        }

        if (ret == REASON_DENIED) {
        if (ret == REASON_DENIED && verifyPackage(callingPackage, callingUid)) {
            final boolean isAllowedPackage =
                    mAllowListWhileInUsePermissionInFgs.contains(callingPackage);
            if (isAllowedPackage) {
@@ -6882,4 +6882,19 @@ public final class ActiveServices {
                /* allowBackgroundActivityStarts */ false)
                != REASON_DENIED;
    }

    /**
     * Checks if a given packageName belongs to a given uid.
     * @param packageName the package of the caller
     * @param uid the uid of the caller
     * @return true or false
     */
    private boolean verifyPackage(String packageName, int uid) {
        if (uid == ROOT_UID || uid == SYSTEM_UID) {
            //System and Root are always allowed
            return true;
        }
        return mAm.getPackageManagerInternal().isSameApp(packageName, uid,
                UserHandle.getUserId(uid));
    }
}