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

Commit d5941978 authored by Jing Ji's avatar Jing Ji Committed by Vineeta Srivastava
Browse files

Allow system app to take ownership of built-in permissions

Previous commit bfed9f34 makes the preloaded system app take
precedence over third-party apps when defining permissions, but
it also makes it be able to override android built-in permissions.

Now allow preloaded system app to take the ownership of built-in
permissions instead of overriding it.

Change-Id: I10d588d0284e4316ea4be552fd6191f33e3c725b
parent 9dfad8c7
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -5960,13 +5960,21 @@ public class PackageManagerService extends IPackageManager.Stub {
                    if (bp != null && !Objects.equals(bp.sourcePackage, p.info.packageName)) {
                        final boolean currentOwnerIsSystem = (bp.perm != null
                                && isSystemApp(bp.perm.owner));
                        if (isSystemApp(p.owner) && !currentOwnerIsSystem) {
                        if (isSystemApp(p.owner)) {
                            if (bp.type == BasePermission.TYPE_BUILTIN && bp.perm == null) {
                                // It's a built-in permission and no owner, take ownership now
                                bp.packageSetting = pkgSetting;
                                bp.perm = p;
                                bp.uid = pkg.applicationInfo.uid;
                                bp.sourcePackage = p.info.packageName;
                            } else if (!currentOwnerIsSystem) {
                                String msg = "New decl " + p.owner + " of permission  "
                                        + p.info.name + " is system; overriding " + bp.sourcePackage;
                                reportSettingsProblem(Log.WARN, msg);
                                bp = null;
                            }
                        }
                    }
                    if (bp == null) {
                        bp = new BasePermission(p.info.name, p.info.packageName,