use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by LineageOS.
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);
mBugReportController = new BugReportPreferenceController(getActivity());
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
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;
}
mBugReportController.displayPreference(getPreferenceScreen());
mBugReportInPowerController.displayPreference(getPreferenceScreen());
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 = addListPreference(WINDOW_ANIMATION_SCALE_KEY);
mTransitionAnimationScale = addListPreference(TRANSITION_ANIMATION_SCALE_KEY);
mAnimatorDurationScale = addListPreference(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();
}
use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by omnirom.
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 omnirom.
the class AddUserWhenLockedPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
RestrictedSwitchPreference restrictedSwitchPreference = (RestrictedSwitchPreference) preference;
int value = Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0);
restrictedSwitchPreference.setChecked(value == 1);
restrictedSwitchPreference.setDisabledByAdmin(mUserCaps.disallowAddUser() ? mUserCaps.getEnforcedAdmin() : null);
}
use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by omnirom.
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);
}
use of com.android.settingslib.RestrictedSwitchPreference in project android_packages_apps_Settings by omnirom.
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);
}
Aggregations