Add config flag in Settings to control whether restricted profiles are offered.

This adds a config resource to specify whether restricted profiles
should be offered as an option when a new user is added. This replaces
the previous check if a device is voice capable, and will be defaulted
to false.

Bug: 202854971
Test: make RunSettingsRoboTests -j40 ROBOTEST_FILTER="com.android.settings.users.UserCapabilitiesTest"
Change-Id: If090fe8d902d6521acfde8c26e801aa4fc4f5ff4
This commit is contained in:
Oli Lan
2022-01-11 12:45:28 +00:00
parent 6649b9b0eb
commit 8aec687b29
4 changed files with 81 additions and 8 deletions

View File

@@ -49,6 +49,7 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private final Map<String, List<EnforcingUser>> mRestrictionSources = new HashMap<>();
private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
private final Set<Integer> mManagedProfiles = new HashSet<>();
private final Set<String> mEnabledTypes = new HashSet<>();
private boolean mIsQuietModeEnabled = false;
private int[] profileIdsForUser = new int[0];
private boolean mUserSwitchEnabled;
@@ -105,6 +106,11 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
mGuestRestrictions.add(restriction);
}
@Implementation
protected boolean hasUserRestriction(String restrictionKey) {
return hasUserRestriction(restrictionKey, UserHandle.of(UserHandle.myUserId()));
}
public static ShadowUserManager getShadow() {
return (ShadowUserManager) Shadow.extract(
RuntimeEnvironment.application.getSystemService(UserManager.class));
@@ -199,4 +205,17 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
public void setSwitchabilityStatus(@UserManager.UserSwitchabilityResult int newStatus) {
mSwitchabilityStatus = newStatus;
}
@Implementation
protected boolean isUserTypeEnabled(String userType) {
return mEnabledTypes.contains(userType);
}
public void setUserTypeEnabled(String type, boolean enabled) {
if (enabled) {
mEnabledTypes.add(type);
} else {
mEnabledTypes.remove(type);
}
}
}