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

Commit b8c0383b authored by Christopher Tate's avatar Christopher Tate
Browse files

Relax duplicate-permission-definition constraints slightly

If the permission being redefined by the install-candidate package is
supplied by the system itself, ignore the redefinition but allow the
install.

Bug 14618942

Change-Id: I3d320e446587e528ae175dcd4782e607729caff7
parent 66c11e1f
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -10207,7 +10207,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) {
@@ -10215,6 +10215,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);
@@ -10222,6 +10226,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);
                        }
                    }
                }
            }