use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by SudaMod.
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 android_packages_apps_Settings by SudaMod.
the class AddUserWhenLockedPreferenceControllerTest method displayPref_NotAdmin_shouldNotDisplay.
@Test
public void displayPref_NotAdmin_shouldNotDisplay() {
when(mUserManager.getUserInfo(anyInt())).thenReturn(mUserInfo);
when(mUserInfo.isAdmin()).thenReturn(false);
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
when(mScreen.getPreferenceCount()).thenReturn(1);
when(mScreen.getPreference(0)).thenReturn(preference);
when(preference.getKey()).thenReturn(mController.getPreferenceKey());
mController.displayPreference(mScreen);
verify(mScreen).removePreference(any(Preference.class));
}
use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by SudaMod.
the class TrustAgentSettings method updateAgents.
private void updateAgents() {
final Context context = getActivity();
if (mAvailableAgents == null) {
mAvailableAgents = findAvailableTrustAgents();
}
if (mLockPatternUtils == null) {
mLockPatternUtils = new LockPatternUtils(getActivity());
}
loadActiveAgents();
PreferenceGroup category = (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
category.removeAll();
final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
final int count = mAvailableAgents.size();
for (int i = 0; i < count; i++) {
AgentInfo agent = mAvailableAgents.valueAt(i);
final RestrictedSwitchPreference preference = new RestrictedSwitchPreference(getPrefContext());
preference.useAdminDisabledSummary(true);
agent.preference = preference;
preference.setPersistent(false);
preference.setTitle(agent.label);
preference.setIcon(agent.icon);
preference.setPersistent(false);
preference.setOnPreferenceChangeListener(this);
preference.setChecked(mActiveAgents.contains(agent.component));
if (admin != null && mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
preference.setChecked(false);
preference.setDisabledByAdmin(admin);
}
category.addPreference(agent.preference);
}
}
use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by DirtyUnicorns.
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 android_packages_apps_Settings by DirtyUnicorns.
the class TrustAgentSettings method updateAgents.
private void updateAgents() {
final Context context = getActivity();
if (mAvailableAgents == null) {
mAvailableAgents = findAvailableTrustAgents();
}
if (mLockPatternUtils == null) {
mLockPatternUtils = new LockPatternUtils(getActivity());
}
loadActiveAgents();
PreferenceGroup category = (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
category.removeAll();
final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
final int count = mAvailableAgents.size();
for (int i = 0; i < count; i++) {
AgentInfo agent = mAvailableAgents.valueAt(i);
final RestrictedSwitchPreference preference = new RestrictedSwitchPreference(getPrefContext());
preference.useAdminDisabledSummary(true);
agent.preference = preference;
preference.setPersistent(false);
preference.setTitle(agent.label);
preference.setIcon(agent.icon);
preference.setPersistent(false);
preference.setOnPreferenceChangeListener(this);
preference.setChecked(mActiveAgents.contains(agent.component));
if (admin != null && mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
preference.setChecked(false);
preference.setDisabledByAdmin(admin);
}
category.addPreference(agent.preference);
}
}
Aggregations