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

Commit 9ae597b6 authored by sunjian's avatar sunjian Committed by Jian Sun
Browse files

Fix Android O: AccountManager API not working in managed profile.

Bug: 64577509
Test: NONE
Change-Id: I25650b2002d392ef9b7f4f4732106b22bc0eaae2
parent 21f34896
Loading
Loading
Loading
Loading
+16 −16
Original line number Original line Diff line number Diff line
@@ -5289,16 +5289,14 @@ public class AccountManagerService
        long identityToken = Binder.clearCallingIdentity();
        long identityToken = Binder.clearCallingIdentity();
        try {
        try {
            packages = mPackageManager.getPackagesForUid(callingUid);
            packages = mPackageManager.getPackagesForUid(callingUid);
        } finally {
            Binder.restoreCallingIdentity(identityToken);
        }
            if (packages == null) {
            if (packages == null) {
                Log.d(TAG, "No packages for callingUid " + callingUid);
                Log.d(TAG, "No packages for callingUid " + callingUid);
                return false;
                return false;
            }
            }
            for (String name : packages) {
            for (String name : packages) {
                try {
                try {
                PackageInfo packageInfo = mPackageManager.getPackageInfo(name, 0 /* flags */);
                    PackageInfo packageInfo =
                        mPackageManager.getPackageInfo(name, 0 /* flags */);
                    if (packageInfo != null
                    if (packageInfo != null
                        && (packageInfo.applicationInfo.privateFlags
                        && (packageInfo.applicationInfo.privateFlags
                            & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
                            & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
@@ -5306,9 +5304,11 @@ public class AccountManagerService
                    }
                    }
                } catch (PackageManager.NameNotFoundException e) {
                } catch (PackageManager.NameNotFoundException e) {
                    Log.d(TAG, "Package not found " + e.getMessage());
                    Log.d(TAG, "Package not found " + e.getMessage());
                return false;
                }
                }
            }
            }
        } finally {
            Binder.restoreCallingIdentity(identityToken);
        }
        return false;
        return false;
    }
    }