Merge "Clear caller identity in doesPackageHaveCallingUid helper method so it can work across users." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f9de2e2471
@@ -1167,11 +1167,16 @@ final class UiModeManagerService extends SystemService {
|
||||
}
|
||||
|
||||
private boolean doesPackageHaveCallingUid(@NonNull String packageName) {
|
||||
int callingUid = mInjector.getCallingUid();
|
||||
int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return getContext().getPackageManager().getPackageUidAsUser(packageName,
|
||||
UserHandle.getCallingUserId()) == mInjector.getCallingUid();
|
||||
callingUserId) == callingUid;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user