Check purely for the presence of a managed profile
including the parent user, as here we care only about the existence of the managed profile. This maintains the behaviour prior to private space changes. Bug: 313128792 Test: manual Test: atest ProfileSelectFragmentTest Change-Id: I1d253f95ca534b48acfdb4c1c8b84368d731dded
This commit is contained in:
@@ -467,6 +467,22 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a profile of specified userType exists. Note that it considers all profiles,
|
||||
* including the disabled profiles and the parent user itself.
|
||||
*/
|
||||
public static boolean doesProfileOfTypeExists(
|
||||
@NonNull UserManager userManager, @ProfileType int userType) {
|
||||
final List<UserInfo> userProfiles = userManager.getProfiles(UserHandle.myUserId());
|
||||
String umUserType = getUmUserType(userType);
|
||||
for (UserInfo profile : userProfiles) {
|
||||
if (Objects.equals(umUserType, profile.userType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getUmUserType(@ProfileType int userType) throws IllegalArgumentException {
|
||||
if (userType == ProfileType.WORK) {
|
||||
return USER_TYPE_PROFILE_MANAGED;
|
||||
|
Reference in New Issue
Block a user