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

Commit fea6e618 authored by Svet Ganov's avatar Svet Ganov Committed by gitbuildkicker
Browse files

Fix a bug in the scoped permission grant

Change-Id: Iaed201396217f3d982a9454676b4a82fa6102754
(cherry picked from commit 36edb5cb)
parent 9db52943
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -433,18 +433,18 @@ public class GrantPermissionsActivity extends OverlayTouchActivity


    private static String[] computeAffectedPermissions(PackageInfo callingPkg,
    private static String[] computeAffectedPermissions(PackageInfo callingPkg,
            String permission) {
            String permission) {
        // For M apps all permissions are affected.
        // For <= N_MR1 apps all permissions are affected.
        if (callingPkg.applicationInfo.targetSdkVersion <= Build.VERSION_CODES.M) {
        if (callingPkg.applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
            return null;
            return null;
        }
        }


        // For M+ apps only the requested permission is affected with addition
        // For N_MR1+ apps only the requested permission is affected with addition
        // to splits of this permission applicable to apps targeting M.
        // to splits of this permission applicable to apps targeting N_MR1.
        String[] permissions = new String[] {permission};
        String[] permissions = new String[] {permission};
        for (PackageParser.SplitPermissionInfo splitPerm : PackageParser.SPLIT_PERMISSIONS) {
        for (PackageParser.SplitPermissionInfo splitPerm : PackageParser.SPLIT_PERMISSIONS) {
            if (splitPerm.targetSdk <= Build.VERSION_CODES.M
            if (splitPerm.targetSdk <= Build.VERSION_CODES.N_MR1
                    || callingPkg.applicationInfo.targetSdkVersion >= splitPerm.targetSdk
                    || callingPkg.applicationInfo.targetSdkVersion >= splitPerm.targetSdk
                    || !ArrayUtils.contains(callingPkg.requestedPermissions, splitPerm.rootPerm)) {
                    || !permission.equals(splitPerm.rootPerm)) {
                continue;
                continue;
            }
            }
            for (int i = 0; i < splitPerm.newPerms.length; i++) {
            for (int i = 0; i < splitPerm.newPerms.length; i++) {