Search in sources :

Example 71 with RestrictedSwitchPreference

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);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 72 with RestrictedSwitchPreference

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);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 73 with RestrictedSwitchPreference

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);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 74 with RestrictedSwitchPreference

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);
        }
    }
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) RestrictedLockUtils(com.android.settingslib.RestrictedLockUtils)

Example 75 with RestrictedSwitchPreference

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);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Aggregations

RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)146 Test (org.junit.Test)101 NotificationChannel (android.app.NotificationChannel)52 Preference (androidx.preference.Preference)23 PreferenceGroup (android.support.v7.preference.PreferenceGroup)15 Preference (android.support.v7.preference.Preference)14 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)10 Before (org.junit.Before)10 SwitchPreference (android.support.v14.preference.SwitchPreference)8 Context (android.content.Context)7 IBinder (android.os.IBinder)7 RemoteException (android.os.RemoteException)7 ListPreference (android.support.v7.preference.ListPreference)7 LockPatternUtils (com.android.internal.widget.LockPatternUtils)7 IStorageManager (android.os.storage.IStorageManager)6 WebViewAppPreferenceController (com.android.settings.webview.WebViewAppPreferenceController)6 AbstractEnableAdbPreferenceController (com.android.settingslib.development.AbstractEnableAdbPreferenceController)6 ContentResolver (android.content.ContentResolver)2 ResolveInfo (android.content.pm.ResolveInfo)2 PersistableBundle (android.os.PersistableBundle)2