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:
@@ -23,6 +23,7 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
@@ -30,7 +31,7 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
public class UserCapabilities {
|
||||
boolean mEnabled = true;
|
||||
boolean mCanAddUser = true;
|
||||
boolean mCanAddRestrictedProfile = true;
|
||||
boolean mCanAddRestrictedProfile;
|
||||
boolean mIsAdmin;
|
||||
boolean mIsGuest;
|
||||
boolean mUserSwitcherEnabled;
|
||||
@@ -57,12 +58,13 @@ public class UserCapabilities {
|
||||
caps.mIsAdmin = myUserInfo.isAdmin();
|
||||
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
|
||||
Context.DEVICE_POLICY_SERVICE);
|
||||
// No restricted profiles for tablets with a device owner, or phones.
|
||||
if (dpm.isDeviceManaged()
|
||||
|| Utils.isVoiceCapable(context)
|
||||
|| !userManager.isUserTypeEnabled(UserManager.USER_TYPE_FULL_RESTRICTED)) {
|
||||
caps.mCanAddRestrictedProfile = false;
|
||||
}
|
||||
|
||||
boolean offerRestricted =
|
||||
context.getResources().getBoolean(R.bool.config_offer_restricted_profiles);
|
||||
caps.mCanAddRestrictedProfile =
|
||||
offerRestricted && !dpm.isDeviceManaged() && userManager.isUserTypeEnabled(
|
||||
UserManager.USER_TYPE_FULL_RESTRICTED);
|
||||
|
||||
caps.updateAddUserCapabilities(context);
|
||||
return caps;
|
||||
}
|
||||
|
Reference in New Issue
Block a user