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

Commit 5468f545 authored by Jing Ji's avatar Jing Ji Committed by Android Git Automerger
Browse files

am d5941978: Allow system app to take ownership of built-in permissions

* commit 'd5941978':
  Allow system app to take ownership of built-in permissions
parents 17eefabd d5941978
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,