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

Commit 1cd6c6ec authored by Nick Kralevich's avatar Nick Kralevich
Browse files

PackageManagerService: honor requestedPermissionsRequired

Don't automatically grant all normal/dangerous permissions. Instead,
check the value of requestedPermissionsRequired to see if it's required.

If the permission is not required, then only grant it if the permission
was previously granted to the application.

Change-Id: I86b1fae530c006d353f9fa22137598bc88253805
parent 952e4805
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -5077,7 +5077,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        final int N = pkg.requestedPermissions.size();
        for (int i=0; i<N; i++) {
            final String name = pkg.requestedPermissions.get(i);
            //final boolean required = pkg.requestedPermssionsRequired.get(i);
            final boolean required = pkg.requestedPermissionsRequired.get(i);
            final BasePermission bp = mSettings.mPermissions.get(name);
            if (DEBUG_INSTALL) {
                if (gp != ps) {
@@ -5091,7 +5091,9 @@ public class PackageManagerService extends IPackageManager.Stub {
                final int level = bp.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
                if (level == PermissionInfo.PROTECTION_NORMAL
                        || level == PermissionInfo.PROTECTION_DANGEROUS) {
                    allowed = true;
                    // If the permission is required, or it's optional and was previously
                    // granted to the application, then allow it. Otherwise deny.
                    allowed = (required || origPermissions.contains(perm));
                } else if (bp.packageSetting == null) {
                    // This permission is invalid; skip it.
                    allowed = false;
@@ -5141,11 +5143,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                            & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
                        // For development permissions, a development permission
                        // is granted only if it was already granted.
                        if (origPermissions.contains(perm)) {
                            allowed = true;
                        } else {
                            allowed = false;
                        }
                        allowed = origPermissions.contains(perm);
                    }
                    if (allowed) {
                        allowedSig = true;