public void onClick(DialogInterface dialog, int which) { if (dialog == mAdbDialog) { if (which == DialogInterface.BUTTON_POSITIVE) { mDialogClicked = true; Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED, 1); mVerifyAppsOverUsb.setEnabled(true); updateVerifyAppsOverUsbOptions(); updateBugreportOptions(); } else { // Reset the toggle mEnableAdb.setChecked(false); } } else if (dialog == mEnableDialog) { if (which == DialogInterface.BUTTON_POSITIVE) { mDialogClicked = true; Settings.Global.putInt( getActivity().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); mLastEnabledState = true; setPrefsEnabledState(mLastEnabledState); } else { // Reset the toggle mEnabledSwitch.setChecked(false); } } }
private void updateAllOptions() { final Context context = getActivity(); final ContentResolver cr = context.getContentResolver(); mHaveDebugSettings = false; updateCheckBox(mEnableAdb, Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) != 0); updateCheckBox( mBugreportInPower, Settings.Secure.getInt(cr, Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0); updateCheckBox( mKeepScreenOn, Settings.Global.getInt(cr, Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0); updateCheckBox(mEnforceReadExternal, isPermissionEnforced(READ_EXTERNAL_STORAGE)); updateCheckBox( mAllowMockLocation, Settings.Secure.getInt(cr, Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0); updateHdcpValues(); updatePasswordSummary(); updateDebuggerOptions(); updateStrictModeVisualOptions(); updatePointerLocationOptions(); updateShowTouchesOptions(); updateFlingerOptions(); updateCpuUsageOptions(); updateHardwareUiOptions(); updateMsaaOptions(); updateTrackFrameTimeOptions(); updateShowHwScreenUpdatesOptions(); updateShowHwLayersUpdatesOptions(); updateShowHwOverdrawOptions(); updateDebugLayoutOptions(); updateAnimationScaleOptions(); updateOverlayDisplayDevicesOptions(); updateOpenGLTracesOptions(); updateEnableTracesOptions(); updateImmediatelyDestroyActivitiesOptions(); updateAppProcessLimitOptions(); updateShowAllANRsOptions(); updateVerifyAppsOverUsbOptions(); updateBugreportOptions(); }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (Utils.isMonkeyRunning()) { return false; } if (preference == mEnableAdb) { if (mEnableAdb.isChecked()) { mDialogClicked = false; if (mAdbDialog != null) dismissDialogs(); mAdbDialog = new AlertDialog.Builder(getActivity()) .setMessage(getActivity().getResources().getString(R.string.adb_warning_message)) .setTitle(R.string.adb_warning_title) .setIconAttribute(android.R.attr.alertDialogIcon) .setPositiveButton(android.R.string.yes, this) .setNegativeButton(android.R.string.no, this) .show(); mAdbDialog.setOnDismissListener(this); } else { Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED, 0); mVerifyAppsOverUsb.setEnabled(false); mVerifyAppsOverUsb.setChecked(false); updateBugreportOptions(); } } else if (preference == mBugreportInPower) { Settings.Secure.putInt( getActivity().getContentResolver(), Settings.Secure.BUGREPORT_IN_POWER_MENU, mBugreportInPower.isChecked() ? 1 : 0); } else if (preference == mKeepScreenOn) { Settings.Global.putInt( getActivity().getContentResolver(), Settings.Global.STAY_ON_WHILE_PLUGGED_IN, mKeepScreenOn.isChecked() ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0); } else if (preference == mEnforceReadExternal) { if (mEnforceReadExternal.isChecked()) { ConfirmEnforceFragment.show(this); } else { setPermissionEnforced(getActivity(), READ_EXTERNAL_STORAGE, false); } } else if (preference == mAllowMockLocation) { Settings.Secure.putInt( getActivity().getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, mAllowMockLocation.isChecked() ? 1 : 0); } else if (preference == mDebugAppPref) { startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP); } else if (preference == mWaitForDebugger) { writeDebuggerOptions(); } else if (preference == mVerifyAppsOverUsb) { writeVerifyAppsOverUsbOptions(); } else if (preference == mStrictMode) { writeStrictModeVisualOptions(); } else if (preference == mPointerLocation) { writePointerLocationOptions(); } else if (preference == mShowTouches) { writeShowTouchesOptions(); } else if (preference == mShowScreenUpdates) { writeShowUpdatesOption(); } else if (preference == mDisableOverlays) { writeDisableOverlaysOption(); } else if (preference == mShowCpuUsage) { writeCpuUsageOptions(); } else if (preference == mImmediatelyDestroyActivities) { writeImmediatelyDestroyActivitiesOptions(); } else if (preference == mShowAllANRs) { writeShowAllANRsOptions(); } else if (preference == mForceHardwareUi) { writeHardwareUiOptions(); } else if (preference == mForceMsaa) { writeMsaaOptions(); } else if (preference == mTrackFrameTime) { writeTrackFrameTimeOptions(); } else if (preference == mShowHwScreenUpdates) { writeShowHwScreenUpdatesOptions(); } else if (preference == mShowHwLayersUpdates) { writeShowHwLayersUpdatesOptions(); } else if (preference == mShowHwOverdraw) { writeShowHwOverdrawOptions(); } else if (preference == mDebugLayout) { writeDebugLayoutOptions(); } else if (preference == mKillAppLongpressBack) { writeKillAppLongpressBackOptions(); } return false; }