use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AddUserWhenLockedPreferenceControllerTest method updateState_Admin_shouldDisplayPreference.
@Test
public void updateState_Admin_shouldDisplayPreference() {
mUserManager.setIsAdminUser(true);
mUserManager.setUserSwitcherEnabled(true);
mUserManager.setSupportsMultipleUsers(true);
final AddUserWhenLockedPreferenceController controller = new AddUserWhenLockedPreferenceController(mContext, "fake_key");
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
controller.updateState(preference);
verify(preference).setVisible(true);
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AddUserWhenLockedPreferenceControllerTest method onPreferenceChange_SettingIsOffWhenPreferenceNotChecked.
@Test
public void onPreferenceChange_SettingIsOffWhenPreferenceNotChecked() {
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
preference.setChecked(false);
mController.onPreferenceChange(preference, Boolean.FALSE);
assertThat(Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0)).isEqualTo(0);
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AddUserWhenLockedPreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.
@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
Global.putInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0);
mController.updateState(preference);
verify(preference).setChecked(false);
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContactSearchPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (preference instanceof RestrictedSwitchPreference) {
final RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setChecked(isChecked());
if (mManagedUser != null) {
final RestrictedLockUtils.EnforcedAdmin enforcedAdmin = RestrictedLockUtilsInternal.checkIfRemoteContactSearchDisallowed(mContext, mManagedUser.getIdentifier());
pref.setDisabledByAdmin(enforcedAdmin);
}
}
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VerifyAppsOverUsbPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
final RestrictedSwitchPreference restrictedPreference = (RestrictedSwitchPreference) preference;
if (!shouldBeEnabled()) {
restrictedPreference.setChecked(false);
restrictedPreference.setDisabledByAdmin(null);
restrictedPreference.setEnabled(false);
return;
}
final EnforcedAdmin enforcingAdmin = mRestrictedLockUtils.checkIfRestrictionEnforced(mContext, UserManager.ENSURE_VERIFY_APPS, UserHandle.myUserId());
if (enforcingAdmin != null) {
restrictedPreference.setChecked(true);
restrictedPreference.setDisabledByAdmin(enforcingAdmin);
return;
}
restrictedPreference.setEnabled(true);
final boolean checked = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, SETTING_VALUE_ON) != SETTING_VALUE_OFF;
restrictedPreference.setChecked(checked);
}
Aggregations