Merge "Fixed DPMS.listForegroundAffiliatedUsers()." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-29 12:41:09 +00:00
committed by Android (Google) Code Review

View File

@@ -8903,17 +8903,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
@Override
public ComponentName getProfileOwnerAsUser(int userHandle) {
public ComponentName getProfileOwnerAsUser(int userId) {
if (!mHasFeature) {
return null;
}
Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId");
Preconditions.checkArgumentNonnegative(userId, "Invalid userId");
final CallerIdentity caller = getCallerIdentity();
Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userHandle));
CallerIdentity caller = getCallerIdentity();
Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userId));
synchronized (getLockObject()) {
return mOwners.getProfileOwnerComponent(userHandle);
return mOwners.getProfileOwnerComponent(userId);
}
}
@@ -9357,19 +9357,20 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public List<UserHandle> listForegroundAffiliatedUsers() {
checkIsDeviceOwner(getCallerIdentity());
int userId = mInjector.binderWithCleanCallingIdentity(() -> getCurrentForegroundUserId());
return mInjector.binderWithCleanCallingIdentity(() -> {
int userId = getCurrentForegroundUserId();
boolean isAffiliated;
synchronized (getLockObject()) {
isAffiliated = isUserAffiliatedWithDeviceLocked(userId);
}
boolean isAffiliated;
synchronized (getLockObject()) {
isAffiliated = isUserAffiliatedWithDeviceLocked(userId);
}
if (!isAffiliated) return Collections.emptyList();
if (!isAffiliated) return Collections.emptyList();
List<UserHandle> users = new ArrayList<>(1);
users.add(UserHandle.of(userId));
List<UserHandle> users = new ArrayList<>(1);
users.add(UserHandle.of(userId));
return users;
return users;
});
}
protected int getProfileParentId(int userHandle) {
@@ -14129,7 +14130,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
private boolean isUserAffiliatedWithDeviceLocked(int userId) {
private boolean isUserAffiliatedWithDeviceLocked(@UserIdInt int userId) {
if (!mOwners.hasDeviceOwner()) {
return false;
}