Merge "Clear caller identity before calling dpm#getAccountTypesWithManagementDisabled" into udc-dev

This commit is contained in:
Kholoud Mohamed
2023-04-16 16:26:14 +00:00
committed by Android (Google) Code Review

View File

@@ -5912,22 +5912,24 @@ public class AccountManagerService
}
private boolean canUserModifyAccountsForType(int userId, String accountType, int callingUid) {
// the managing app can always modify accounts
if (isProfileOwner(callingUid)) {
return true;
}
DevicePolicyManager dpm = (DevicePolicyManager) mContext
.getSystemService(Context.DEVICE_POLICY_SERVICE);
String[] typesArray = dpm.getAccountTypesWithManagementDisabledAsUser(userId);
if (typesArray == null) {
return true;
}
for (String forbiddenType : typesArray) {
if (forbiddenType.equals(accountType)) {
return false;
return Binder.withCleanCallingIdentity(() -> {
// the managing app can always modify accounts
if (isProfileOwner(callingUid)) {
return true;
}
}
return true;
DevicePolicyManager dpm = (DevicePolicyManager) mContext
.getSystemService(Context.DEVICE_POLICY_SERVICE);
String[] typesArray = dpm.getAccountTypesWithManagementDisabledAsUser(userId);
if (typesArray == null) {
return true;
}
for (String forbiddenType : typesArray) {
if (forbiddenType.equals(accountType)) {
return false;
}
}
return true;
});
}
private boolean isProfileOwner(int uid) {