Create new system API in UserHandle to get uid
For the incoming connectivity mainline, it need to compute the intersection of a set of uids and appIds for the permission control. As @UserIdInt values are internal implementation details of the OS, any mainline modules should use strongly-typed UserHandle arguments. Thus, create a new API that accepts UserHandle and appId to get the computed uid. Bug: 170598012 Test: atest FrameworksNetTests Change-Id: I046546d2c5c76eac7a251e63e4234776975bf2bc
This commit is contained in:
@@ -265,7 +265,10 @@ public class PermissionMonitor implements PackageManagerInternal.PackageListObse
|
|||||||
for (Entry<Integer, Boolean> app : apps.entrySet()) {
|
for (Entry<Integer, Boolean> app : apps.entrySet()) {
|
||||||
List<Integer> list = app.getValue() ? system : network;
|
List<Integer> list = app.getValue() ? system : network;
|
||||||
for (int user : users) {
|
for (int user : users) {
|
||||||
list.add(UserHandle.getUid(user, app.getKey()));
|
final UserHandle handle = UserHandle.of(user);
|
||||||
|
if (handle == null) continue;
|
||||||
|
|
||||||
|
list.add(UserHandle.getUid(handle, app.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -550,7 +553,10 @@ public class PermissionMonitor implements PackageManagerInternal.PackageListObse
|
|||||||
for (UidRange range : ranges) {
|
for (UidRange range : ranges) {
|
||||||
for (int userId = range.getStartUser(); userId <= range.getEndUser(); userId++) {
|
for (int userId = range.getStartUser(); userId <= range.getEndUser(); userId++) {
|
||||||
for (int appId : appIds) {
|
for (int appId : appIds) {
|
||||||
final int uid = UserHandle.getUid(userId, appId);
|
final UserHandle handle = UserHandle.of(userId);
|
||||||
|
if (handle == null) continue;
|
||||||
|
|
||||||
|
final int uid = UserHandle.getUid(handle, appId);
|
||||||
if (range.contains(uid)) {
|
if (range.contains(uid)) {
|
||||||
result.add(uid);
|
result.add(uid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user