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

Commit f4863616 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android Git Automerger
Browse files

am c77d3b16: am f667c8d3: Merge "grantPermissionsLPw: introduce...

am c77d3b16: am f667c8d3: Merge "grantPermissionsLPw: introduce isNewPlatformPermissionForPackage" into jb-mr2-dev

* commit 'c77d3b16':
  grantPermissionsLPw: introduce isNewPlatformPermissionForPackage
parents 2a9abe9e c77d3b16
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -5182,22 +5182,10 @@ public class PackageManagerService extends IPackageManager.Stub {
                    // If this is an existing, non-system package, then
                    // we can't add any new permissions to it.
                    if (!allowedSig && !gp.grantedPermissions.contains(perm)) {
                        allowed = false;
                        // Except...  if this is a permission that was added
                        // to the platform (note: need to only do this when
                        // updating the platform).
                        final int NP = PackageParser.NEW_PERMISSIONS.length;
                        for (int ip=0; ip<NP; ip++) {
                            final PackageParser.NewPermissionInfo npi
                                    = PackageParser.NEW_PERMISSIONS[ip];
                            if (npi.name.equals(perm)
                                    && pkg.applicationInfo.targetSdkVersion < npi.sdkVersion) {
                                allowed = true;
                                Log.i(TAG, "Auto-granting " + perm + " to old pkg "
                                        + pkg.packageName);
                                break;
                            }
                        }
                        allowed = isNewPlatformPermissionForPackage(perm, pkg);
                    }
                }
                if (allowed) {
@@ -5243,6 +5231,23 @@ public class PackageManagerService extends IPackageManager.Stub {
        ps.haveGids = true;
    }

    private boolean isNewPlatformPermissionForPackage(String perm, PackageParser.Package pkg) {
        boolean allowed = false;
        final int NP = PackageParser.NEW_PERMISSIONS.length;
        for (int ip=0; ip<NP; ip++) {
            final PackageParser.NewPermissionInfo npi
                    = PackageParser.NEW_PERMISSIONS[ip];
            if (npi.name.equals(perm)
                    && pkg.applicationInfo.targetSdkVersion < npi.sdkVersion) {
                allowed = true;
                Log.i(TAG, "Auto-granting " + perm + " to old pkg "
                        + pkg.packageName);
                break;
            }
        }
        return allowed;
    }

    private boolean doSignaturePermission(String perm, PackageParser.Package pkg,
                                          BasePermission bp, HashSet<String> origPermissions) {
        boolean allowed;