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

Commit 81a47cd6 authored by Alex Chau's avatar Alex Chau
Browse files

Clear calling identity when calling getPackageInfo in AMS.isSystemUid

- Without this, calling removeAccount in secondary user will crash, as the calling app may not have the permission required by getPackageInfo

Bug: 65280359
Test: Remove account from profile owner is successful
Change-Id: I4e5931732fd6797bb8429e8fa772022018e878c2
parent dc4cb146
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -5595,13 +5595,11 @@ public class AccountManagerService
        long ident = Binder.clearCallingIdentity();
        try {
            packages = mPackageManager.getPackagesForUid(callingUid);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
            if (packages != null) {
                for (String name : packages) {
                    try {
                    PackageInfo packageInfo = mPackageManager.getPackageInfo(name, 0 /* flags */);
                        PackageInfo packageInfo =
                                mPackageManager.getPackageInfo(name, 0 /* flags */);
                        if (packageInfo != null
                                && (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
                                != 0) {
@@ -5614,6 +5612,9 @@ public class AccountManagerService
            } else {
                Log.w(TAG, "No known packages with uid " + callingUid);
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        return false;
    }