/**
   * Invoked on each preference click in this hierarchy, overrides PreferenceActivity's
   * implementation. Used to make sure we track the preference click events.
   */
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    /** TODO: Refactor and get rid of the if's using subclasses */
    if (mGsmUmtsOptions != null && mGsmUmtsOptions.preferenceTreeClick(preference) == true) {
      return true;
    } else if (mCdmaOptions != null && mCdmaOptions.preferenceTreeClick(preference) == true) {
      if (Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {

        mClickedPreference = preference;

        // In ECM mode launch ECM app dialog
        startActivityForResult(
            new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
            REQUEST_CODE_EXIT_ECM);
      }
      return true;
    } else if (preference == mButtonPreferredNetworkMode) {
      // displays the value taken from the Settings.System
      int settingsNetworkMode = getPreferredNetworkMode();
      mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
      return true;
    } else {
      // if the button is anything but the simple toggle preference,
      // we'll need to disable all preferences to reject all click
      // events until the sub-activity's UI comes up.
      preferenceScreen.setEnabled(false);
      // Let the intents be launched by the Preference manager
      return false;
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case REQUEST_CODE_EXIT_ECM:
        Boolean isChoiceYes =
            data.getBooleanExtra(EmergencyCallbackModeExitDialog.EXTRA_EXIT_ECM_RESULT, false);
        if (isChoiceYes) {
          // If the phone exits from ECM mode, show the CDMA Options
          mCdmaOptions.showDialog(mClickedPreference);
        } else {
          // do nothing
        }
        break;

      default:
        break;
    }
  }