Merge "Clear calling identity when calling getPackageInfo in AMS.isSystemUid"

This commit is contained in:
TreeHugger Robot
2018-01-03 14:59:21 +00:00
committed by Android (Google) Code Review

View File

@@ -5595,25 +5595,26 @@ public class AccountManagerService
long ident = Binder.clearCallingIdentity();
try {
packages = mPackageManager.getPackagesForUid(callingUid);
if (packages != null) {
for (String name : packages) {
try {
PackageInfo packageInfo =
mPackageManager.getPackageInfo(name, 0 /* flags */);
if (packageInfo != null
&& (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
return true;
}
} catch (NameNotFoundException e) {
Log.w(TAG, String.format("Could not find package [%s]", name), e);
}
}
} else {
Log.w(TAG, "No known packages with uid " + callingUid);
}
} finally {
Binder.restoreCallingIdentity(ident);
}
if (packages != null) {
for (String name : packages) {
try {
PackageInfo packageInfo = mPackageManager.getPackageInfo(name, 0 /* flags */);
if (packageInfo != null
&& (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
return true;
}
} catch (NameNotFoundException e) {
Log.w(TAG, String.format("Could not find package [%s]", name), e);
}
}
} else {
Log.w(TAG, "No known packages with uid " + callingUid);
}
return false;
}