Call getPackageUidAsUser instead of getPackageUid

PackageManager.java has a lot of similar options for getPackageUid, 3 of
which are:
1. getPackageUid(String packageName, @PackageInfoFlags int flags)
2. getPackageUid(String packageName, @PackageInfoFlags int flags,
@UserIdInt)
3. getPackageUidAsUser(String packageName, @UserIdInt int userId)

The function being called here in set appop getPackageUid is calling 1st
method but passing userId. Passing the user ID is accepted as it is also
int, but the uid of the current user is returned.

Test: manual
Change-Id: I032df4a3e666ebb3efee673153bb75fa4c571e83
This commit is contained in:
Abhijeet Kaur
2020-01-29 18:55:49 +00:00
parent 04346f0186
commit 62477e502e

View File

@@ -4325,7 +4325,7 @@ public class AppOpsService extends IAppOpsService.Stub {
} else if (shell.targetsUid && shell.packageName != null) {
try {
final int uid = shell.mInternal.mContext.getPackageManager()
.getPackageUid(shell.packageName, shell.userId);
.getPackageUidAsUser(shell.packageName, shell.userId);
shell.mInterface.setUidMode(shell.op, uid, mode);
} catch (PackageManager.NameNotFoundException e) {
return -1;