Search in sources :

Example 11 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by omnirom.

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

Example 12 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

the class DevelopmentSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mWebViewUpdateService = WebViewFactory.getUpdateService();
    mOemLockManager = (OemLockManager) getSystemService(Context.OEM_LOCK_SERVICE);
    mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mUm = (UserManager) getSystemService(Context.USER_SERVICE);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
    mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
    mVerifyAppsOverUsbController = new VerifyAppsOverUsbPreferenceController(getActivity());
    mCameraLaserSensorController = new CameraLaserSensorPreferenceController(getActivity());
    setIfOnlyAvailableForAdmins(true);
    if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
        // Block access to developer options if the user is not the owner, if user policy
        // restricts it, or if the device has not been provisioned
        mUnavailable = true;
        addPreferencesFromResource(R.xml.placeholder_prefs);
        return;
    }
    addPreferencesFromResource(R.xml.development_prefs);
    final PreferenceGroup debugDebuggingCategory = (PreferenceGroup) findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
    mEnableAdbController = new EnableAdbPreferenceController(getActivity());
    mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
    mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
    if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
        if (debugDebuggingCategory != null) {
            debugDebuggingCategory.removePreference(mClearAdbKeys);
        }
    }
    mAllPrefs.add(mClearAdbKeys);
    mEnableTerminal = findAndInitSwitchPref(ENABLE_TERMINAL);
    if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
        debugDebuggingCategory.removePreference(mEnableTerminal);
        mEnableTerminal = null;
    }
    mTelephonyMonitorController.displayPreference(getPreferenceScreen());
    mWebViewAppPrefController.displayPreference(getPreferenceScreen());
    mEnableAdbController.displayPreference(getPreferenceScreen());
    mCameraLaserSensorController.displayPreference(getPreferenceScreen());
    mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
    mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
    mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
    if (!showEnableOemUnlockPreference(getActivity())) {
        removePreference(mEnableOemUnlock);
        mEnableOemUnlock = null;
    }
    mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
    mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
    mPassword = findPreference(LOCAL_BACKUP_PASSWORD);
    mAllPrefs.add(mPassword);
    if (!mUm.isAdminUser()) {
        disableForUser(mClearAdbKeys);
        disableForUser(mEnableTerminal);
        disableForUser(mPassword);
    }
    mDebugAppPref = findPreference(DEBUG_APP_KEY);
    mAllPrefs.add(mDebugAppPref);
    mWaitForDebugger = findAndInitSwitchPref(WAIT_FOR_DEBUGGER_KEY);
    mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
    mAllPrefs.add(mMockLocationAppPref);
    mVerifyAppsOverUsbController.displayPreference(getPreferenceScreen());
    mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
    mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
    mShowTouches = findAndInitSwitchPref(SHOW_TOUCHES_KEY);
    mShowScreenUpdates = findAndInitSwitchPref(SHOW_SCREEN_UPDATES_KEY);
    mDisableOverlays = findAndInitSwitchPref(DISABLE_OVERLAYS_KEY);
    mForceHardwareUi = findAndInitSwitchPref(FORCE_HARDWARE_UI_KEY);
    mForceMsaa = findAndInitSwitchPref(FORCE_MSAA_KEY);
    mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
    mShowNonRectClip = addListPreference(SHOW_NON_RECTANGULAR_CLIP_KEY);
    mShowHwScreenUpdates = findAndInitSwitchPref(SHOW_HW_SCREEN_UPDATES_KEY);
    mShowHwLayersUpdates = findAndInitSwitchPref(SHOW_HW_LAYERS_UPDATES_KEY);
    mDebugLayout = findAndInitSwitchPref(DEBUG_LAYOUT_KEY);
    mForceRtlLayout = findAndInitSwitchPref(FORCE_RTL_LAYOUT_KEY);
    mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
    mDebugHwRenderer = addListPreference(DEBUG_HW_RENDERER_KEY);
    mWifiDisplayCertification = findAndInitSwitchPref(WIFI_DISPLAY_CERTIFICATION_KEY);
    mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
    mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
    mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
    mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
    mTetheringHardwareOffload = findAndInitSwitchPref(TETHERING_HARDWARE_OFFLOAD);
    mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
    if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
        mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
    } else {
        mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
        if (mLogpersist != null) {
            mLogpersist.setEnabled(false);
            if (debugDebuggingCategory != null) {
                debugDebuggingCategory.removePreference(mLogpersist);
            }
        }
        mLogpersist = null;
    }
    mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
    mBluetoothShowDevicesWithoutNames = findAndInitSwitchPref(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_KEY);
    mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
    mBluetoothEnableInbandRinging = findAndInitSwitchPref(BLUETOOTH_ENABLE_INBAND_RINGING_KEY);
    if (!BluetoothHeadset.isInbandRingingSupported(getContext())) {
        removePreference(mBluetoothEnableInbandRinging);
        mBluetoothEnableInbandRinging = null;
    }
    mBluetoothSelectAvrcpVersion = addListPreference(BLUETOOTH_SELECT_AVRCP_VERSION_KEY);
    mBluetoothSelectA2dpCodec = addListPreference(BLUETOOTH_SELECT_A2DP_CODEC_KEY);
    mBluetoothSelectA2dpSampleRate = addListPreference(BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY);
    mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY);
    mBluetoothSelectA2dpChannelMode = addListPreference(BLUETOOTH_SELECT_A2DP_CHANNEL_MODE_KEY);
    mBluetoothSelectA2dpLdacPlaybackQuality = addListPreference(BLUETOOTH_SELECT_A2DP_LDAC_PLAYBACK_QUALITY_KEY);
    initBluetoothConfigurationValues();
    mWindowAnimationScale = findAndInitAnimationScalePreference(WINDOW_ANIMATION_SCALE_KEY);
    mTransitionAnimationScale = findAndInitAnimationScalePreference(TRANSITION_ANIMATION_SCALE_KEY);
    mAnimatorDurationScale = findAndInitAnimationScalePreference(ANIMATOR_DURATION_SCALE_KEY);
    mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
    mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
    mUSBAudio = findAndInitSwitchPref(USB_AUDIO_KEY);
    mForceResizable = findAndInitSwitchPref(FORCE_RESIZABLE_KEY);
    mImmediatelyDestroyActivities = (SwitchPreference) findPreference(IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
    mAllPrefs.add(mImmediatelyDestroyActivities);
    mResetSwitchPrefs.add(mImmediatelyDestroyActivities);
    mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
    mShowAllANRs = (SwitchPreference) findPreference(SHOW_ALL_ANRS_KEY);
    mAllPrefs.add(mShowAllANRs);
    mResetSwitchPrefs.add(mShowAllANRs);
    mShowNotificationChannelWarnings = (SwitchPreference) findPreference(SHOW_NOTIFICATION_CHANNEL_WARNINGS_KEY);
    mAllPrefs.add(mShowNotificationChannelWarnings);
    mResetSwitchPrefs.add(mShowNotificationChannelWarnings);
    Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
    if (hdcpChecking != null) {
        mAllPrefs.add(hdcpChecking);
        removePreferenceForProduction(hdcpChecking);
    }
    Preference convertFbePreference = findPreference(KEY_CONVERT_FBE);
    try {
        IBinder service = ServiceManager.getService("mount");
        IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
        if (!storageManager.isConvertibleToFBE()) {
            removePreference(KEY_CONVERT_FBE);
        } else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
            convertFbePreference.setEnabled(false);
            convertFbePreference.setSummary(getResources().getString(R.string.convert_to_file_encryption_done));
        }
    } catch (RemoteException e) {
        removePreference(KEY_CONVERT_FBE);
    }
    mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
    if (!SystemProperties.getBoolean("ro.build.ab_update", false)) {
        removePreference(mOtaDisableAutomaticUpdate);
        mOtaDisableAutomaticUpdate = null;
    }
    mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
    mColorModePreference.updateCurrentAndSupported();
    if (mColorModePreference.getColorModeCount() < 2 || getContext().getResources().getConfiguration().isScreenWideColorGamut()) {
        removePreference(KEY_COLOR_MODE);
        mColorModePreference = null;
    }
    mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
    if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
        mAllPrefs.add(mColorTemperaturePreference);
        mResetSwitchPrefs.add(mColorTemperaturePreference);
    } else {
        removePreference(COLOR_TEMPERATURE_KEY);
        mColorTemperaturePreference = null;
    }
    mDevelopmentTools = (PreferenceScreen) findPreference(DEVELOPMENT_TOOLS);
    mAllPrefs.add(mDevelopmentTools);
    mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
    mRootAccess.setOnPreferenceChangeListener(this);
    mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
    mRootAppops.setOnPreferenceClickListener(this);
    if (!removeRootOptionsIfRequired()) {
        if (FileUtils.fileExists("/system/xbin/su")) {
            mRootAccess.setEntries(R.array.root_access_entries);
            mRootAccess.setEntryValues(R.array.root_access_values);
        } else {
            mRootAccess.setEntries(R.array.root_access_entries_adb);
            mRootAccess.setEntryValues(R.array.root_access_values_adb);
        }
        mAllPrefs.add(mRootAccess);
        mAllPrefs.add(mRootAppops);
    }
    addDashboardCategoryPreferences();
}
Also used : WebViewAppPreferenceController(com.android.settings.webview.WebViewAppPreferenceController) IStorageManager(android.os.storage.IStorageManager) IBinder(android.os.IBinder) ListPreference(android.support.v7.preference.ListPreference) AnimationScalePreference(com.android.settings.AnimationScalePreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) PreferenceGroup(android.support.v7.preference.PreferenceGroup) AbstractEnableAdbPreferenceController(com.android.settingslib.development.AbstractEnableAdbPreferenceController) RemoteException(android.os.RemoteException)

Example 13 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

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);
    }
}
Also used : Context(android.content.Context) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) LockPatternUtils(com.android.internal.widget.LockPatternUtils) PreferenceGroup(android.support.v7.preference.PreferenceGroup) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 14 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

the class AddUserWhenLockedPreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.

@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
    final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
    Global.putInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 1);
    mController.updateState(preference);
    verify(preference).setChecked(true);
}
Also used : RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Test(org.junit.Test)

Example 15 with RestrictedSwitchPreference

use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by crdroidandroid.

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)

Aggregations

RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)250 Test (org.junit.Test)181 NotificationChannel (android.app.NotificationChannel)105 NotificationBackend (com.android.settings.notification.NotificationBackend)60 Preference (androidx.preference.Preference)48 Before (org.junit.Before)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)15 Preference (android.support.v7.preference.Preference)14 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)13 Context (android.content.Context)8 SwitchPreference (android.support.v14.preference.SwitchPreference)8 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 Intent (android.content.Intent)5 BroadcastReceiver (android.content.BroadcastReceiver)4