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

Commit 5a2e9ff0 authored by Qaweck's avatar Qaweck Committed by Danny Baumann
Browse files

Fix bluetooth and data enable with ProfileManager

Handle the case of system uid in AppOpsManager

Change-Id: I5f9c3ba2e2ed0b1c825b995bf2724066ae796bb4
parent 995a2b30
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -219,12 +219,14 @@ public class AppOpsService extends IAppOpsService.Stub {
                Iterator<Ops> it = pkgs.values().iterator();
                Iterator<Ops> it = pkgs.values().iterator();
                while (it.hasNext()) {
                while (it.hasNext()) {
                    Ops ops = it.next();
                    Ops ops = it.next();
                    int curUid;
                    int curUid = -1;
                    try {
                    try {
                        curUid = mContext.getPackageManager().getPackageUid(ops.packageName,
                        curUid = mContext.getPackageManager().getPackageUid(ops.packageName,
                                UserHandle.getUserId(ops.uid));
                                UserHandle.getUserId(ops.uid));
                    } catch (NameNotFoundException e) {
                    } catch (NameNotFoundException e) {
                        curUid = -1;
                        if ("android".equals(ops.packageName)) {
                            curUid = Process.SYSTEM_UID;
                        }
                    }
                    }
                    if (curUid != ops.uid) {
                    if (curUid != ops.uid) {
                        Slog.i(TAG, "Pruning old package " + ops.packageName
                        Slog.i(TAG, "Pruning old package " + ops.packageName
@@ -819,6 +821,8 @@ public class AppOpsService extends IAppOpsService.Stub {
            packageName = "root";
            packageName = "root";
        } else if (uid == Process.SHELL_UID) {
        } else if (uid == Process.SHELL_UID) {
            packageName = "com.android.shell";
            packageName = "com.android.shell";
        } else if (uid == Process.SYSTEM_UID) {
            packageName = "android";
        }
        }
        Ops ops = pkgOps.get(packageName);
        Ops ops = pkgOps.get(packageName);
        if (ops == null) {
        if (ops == null) {
@@ -827,7 +831,7 @@ public class AppOpsService extends IAppOpsService.Stub {
            }
            }
            // This is the first time we have seen this package name under this uid,
            // This is the first time we have seen this package name under this uid,
            // so let's make sure it is valid.
            // so let's make sure it is valid.
            if (uid != 0) {
            if (uid != 0 && uid != Process.SYSTEM_UID) {
                final long ident = Binder.clearCallingIdentity();
                final long ident = Binder.clearCallingIdentity();
                try {
                try {
                    int pkgUid = -1;
                    int pkgUid = -1;