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

Commit f9fcfaae authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Relax duplicate-permission-definition constraints slightly" into lmp-preview-dev

parents 91b7d2b4 b8c0383b
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -10204,7 +10204,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        synchronized (mPackages) {
            // Check whether the newly-scanned package wants to define an already-defined perm
            int N = pkg.permissions.size();
            for (int i = 0; i < N; i++) {
            for (int i = N-1; i >= 0; i--) {
                PackageParser.Permission perm = pkg.permissions.get(i);
                BasePermission bp = mSettings.mPermissions.get(perm.info.name);
                if (bp != null) {
@@ -10212,6 +10212,10 @@ public class PackageManagerService extends IPackageManager.Stub {
                    // also includes the "updating the same package" case, of course.
                    if (compareSignatures(bp.packageSetting.signatures.mSignatures,
                            pkg.mSignatures) != PackageManager.SIGNATURE_MATCH) {
                        // If the owning package is the system itself, we log but allow
                        // install to proceed; we fail the install on all other permission
                        // redefinitions.
                        if (!bp.sourcePackage.equals("android")) {
                            Slog.w(TAG, "Package " + pkg.packageName
                                    + " attempting to redeclare permission " + perm.info.name
                                    + " already owned by " + bp.sourcePackage);
@@ -10219,6 +10223,12 @@ public class PackageManagerService extends IPackageManager.Stub {
                            res.origPermission = perm.info.name;
                            res.origPackage = bp.sourcePackage;
                            return;
                        } else {
                            Slog.w(TAG, "Package " + pkg.packageName
                                    + " attempting to redeclare system permission "
                                    + perm.info.name + "; ignoring new declaration");
                            pkg.permissions.remove(i);
                        }
                    }
                }
            }