use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MinImportancePreferenceControllerTest method testUpdateState_notConfigurable.
@Test
public void testUpdateState_notConfigurable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
mController.onResume(appRow, channel, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
assertFalse(pref.isEnabled());
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MinImportancePreferenceControllerTest method testUpdateState_defaultApp.
@Test
public void testUpdateState_defaultApp() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
mController.onResume(appRow, channel, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
assertTrue(pref.isEnabled());
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TrustAgentsPreferenceControllerTest method onStart_hasRestrictedTructAgent_shouldAddThreeUnchangeablePreferences.
@Test
public void onStart_hasRestrictedTructAgent_shouldAddThreeUnchangeablePreferences() {
final List<ResolveInfo> availableAgents = createFakeAvailableAgents();
for (ResolveInfo rInfo : availableAgents) {
ShadowTrustAgentManager.grantPermissionToResolveInfo(rInfo);
}
mPackageManager.setResolveInfosForIntent(TEST_INTENT, availableAgents);
ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures(DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS);
mController.displayPreference(mPreferenceScreen);
mController.onStart();
assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(3);
for (int i = 0; i < mPreferenceScreen.getPreferenceCount(); i++) {
RestrictedSwitchPreference preference = (RestrictedSwitchPreference) mPreferenceScreen.getPreference(i);
assertThat(preference.isDisabledByAdmin()).isTrue();
}
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TrustAgentsPreferenceControllerTest method onStart_hasUnrestrictedTrustAgent_shouldAddThreeChangeablePreferences.
@Test
public void onStart_hasUnrestrictedTrustAgent_shouldAddThreeChangeablePreferences() {
ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures(0);
final List<ResolveInfo> availableAgents = createFakeAvailableAgents();
for (ResolveInfo rInfo : availableAgents) {
ShadowTrustAgentManager.grantPermissionToResolveInfo(rInfo);
}
mPackageManager.setResolveInfosForIntent(TEST_INTENT, availableAgents);
mController.displayPreference(mPreferenceScreen);
mController.onStart();
assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(3);
for (int i = 0; i < mPreferenceScreen.getPreferenceCount(); i++) {
RestrictedSwitchPreference preference = (RestrictedSwitchPreference) mPreferenceScreen.getPreference(i);
assertThat(preference.isDisabledByAdmin()).isFalse();
}
}
use of com.android.settingslib.RestrictedSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AllowSoundPreferenceControllerTest method testOnPreferenceChange_off.
@Test
public void testOnPreferenceChange_off() {
NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
mController.displayPreference(mScreen);
mController.updateState(pref);
pref.setChecked(false);
mController.onPreferenceChange(pref, false);
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
assertEquals(IMPORTANCE_LOW, mController.mChannel.getImportance());
verify(mImportanceListener, times(1)).onImportanceChanged();
}
Aggregations