コード例 #1
0
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    if (Utils.isMonkeyRunning()) {
      return false;
    }

    if (preference == mEnableAdb) {
      if (mEnableAdb.isChecked()) {
        mOkClicked = false;
        if (mOkDialog != null) dismissDialog();
        mOkDialog =
            new AlertDialog.Builder(getActivity())
                .setMessage(getActivity().getResources().getString(R.string.adb_warning_message))
                .setTitle(R.string.adb_warning_title)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, this)
                .setNegativeButton(android.R.string.no, this)
                .show();
        mOkDialog.setOnDismissListener(this);
      } else {
        Settings.Secure.putInt(getActivity().getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
      }
    } else if (preference == mKeepScreenOn) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.STAY_ON_WHILE_PLUGGED_IN,
          mKeepScreenOn.isChecked()
              ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
              : 0);
    } else if (preference == mAllowMockLocation) {
      Settings.Secure.putInt(
          getActivity().getContentResolver(),
          Settings.Secure.ALLOW_MOCK_LOCATION,
          mAllowMockLocation.isChecked() ? 1 : 0);
    } else if (preference == mStrictMode) {
      writeStrictModeVisualOptions();
    } else if (preference == mPointerLocation) {
      writePointerLocationOptions();
    } else if (preference == mShowTouches) {
      writeShowTouchesOptions();
    } else if (preference == mShowScreenUpdates) {
      writeFlingerOptions();
    } else if (preference == mShowCpuUsage) {
      writeCpuUsageOptions();
    } else if (preference == mImmediatelyDestroyActivities) {
      writeImmediatelyDestroyActivitiesOptions();
    } else if (preference == mShowAllANRs) {
      writeShowAllANRsOptions();
    } else if (preference == mForceHardwareUi) {
      writeHardwareUiOptions();
    }

    return false;
  }
  @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;
  }