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

Commit 876f2662 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix AccountManagerService caused by empty package names list."

parents d2bd42e7 5e46e573
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -4933,21 +4933,20 @@ public class AccountManagerService
    }

    private boolean isPrivileged(int callingUid) {
        final int callingUserId = UserHandle.getUserId(callingUid);

        final PackageManager userPackageManager;
        String[] packages;
        long identityToken = Binder.clearCallingIdentity();
        try {
            userPackageManager = mContext.createPackageContextAsUser(
                    "android", 0, new UserHandle(callingUserId)).getPackageManager();
        } catch (NameNotFoundException e) {
            Log.d(TAG, "Package not found " + e.getMessage());
            packages = mPackageManager.getPackagesForUid(callingUid);
        } finally {
            Binder.restoreCallingIdentity(identityToken);
        }
        if (packages == null) {
            Log.d(TAG, "No packages for callingUid " + callingUid);
            return false;
        }

        String[] packages = userPackageManager.getPackagesForUid(callingUid);
        for (String name : packages) {
            try {
                PackageInfo packageInfo = userPackageManager.getPackageInfo(name, 0 /* flags */);
                PackageInfo packageInfo = mPackageManager.getPackageInfo(name, 0 /* flags */);
                if (packageInfo != null
                        && (packageInfo.applicationInfo.privateFlags
                                & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
@@ -5393,6 +5392,9 @@ public class AccountManagerService
        if (user != null && user.isRestricted()) {
            String[] packages =
                    mPackageManager.getPackagesForUid(callingUid);
            if (packages == null) {
                packages = new String[] {};
            }
            // If any of the packages is a visible listed package, return the full set,
            // otherwise return non-shared accounts only.
            // This might be a temporary way to specify a visible list