Merge "Clear calling identity when accessing isProfileOwner and listAllOwners" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0c2d1458f2
@@ -1207,16 +1207,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
List<OwnerDto> listAllOwners() {
|
||||
Preconditions.checkCallAuthorization(
|
||||
hasCallingOrSelfPermission(permission.MANAGE_DEVICE_ADMINS));
|
||||
|
||||
List<OwnerDto> owners = mOwners.listAllOwners();
|
||||
synchronized (getLockObject()) {
|
||||
for (int i = 0; i < owners.size(); i++) {
|
||||
OwnerDto owner = owners.get(i);
|
||||
owner.isAffiliated = isUserAffiliatedWithDeviceLocked(owner.userId);
|
||||
return mInjector.binderWithCleanCallingIdentity(() -> {
|
||||
List<OwnerDto> owners = mOwners.listAllOwners();
|
||||
synchronized (getLockObject()) {
|
||||
for (int i = 0; i < owners.size(); i++) {
|
||||
OwnerDto owner = owners.get(i);
|
||||
owner.isAffiliated = isUserAffiliatedWithDeviceLocked(owner.userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return owners;
|
||||
return owners;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8342,7 +8342,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
}
|
||||
|
||||
public boolean isProfileOwner(ComponentName who, int userId) {
|
||||
final ComponentName profileOwner = getProfileOwnerAsUser(userId);
|
||||
final ComponentName profileOwner = mInjector.binderWithCleanCallingIdentity(() ->
|
||||
getProfileOwnerAsUser(userId));
|
||||
return who != null && who.equals(profileOwner);
|
||||
}
|
||||
|
||||
@@ -8359,7 +8360,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
*/
|
||||
public boolean isProfileOwner(CallerIdentity caller) {
|
||||
synchronized (getLockObject()) {
|
||||
final ComponentName profileOwner = getProfileOwnerAsUser(caller.getUserId());
|
||||
final ComponentName profileOwner = mInjector.binderWithCleanCallingIdentity(() ->
|
||||
getProfileOwnerAsUser(caller.getUserId()));
|
||||
// No profile owner.
|
||||
if (profileOwner == null) {
|
||||
return false;
|
||||
@@ -8982,7 +8984,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
Preconditions.checkArgumentNonnegative(userId, "Invalid userId");
|
||||
|
||||
CallerIdentity caller = getCallerIdentity();
|
||||
Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userId));
|
||||
Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userId)
|
||||
|| hasFullCrossUsersPermission(caller, userId));
|
||||
|
||||
synchronized (getLockObject()) {
|
||||
return mOwners.getProfileOwnerComponent(userId);
|
||||
|
||||
Reference in New Issue
Block a user