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

Commit 93e9e720 authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am ba6e8ae5: Merge "Relax duplicate-permission-definition constraints...

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

* commit 'ba6e8ae5d2a364799fd6bc84179e33b6731e574b':
  Relax duplicate-permission-definition constraints slightly
parents 02a9c359 f9fcfaae
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -10266,7 +10266,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) {
@@ -10274,6 +10274,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);
@@ -10281,6 +10285,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);
                        }
                    }
                }
            }