/**
   * 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;
    }
  }
 private void setPreferredNetworkMode(int nwMode) {
   android.provider.Settings.Secure.putIntAtIndex(
       mPhone.getContext().getContentResolver(),
       android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
       mSubscription,
       nwMode);
   // Refresh the GSM UMTS options UI on network mode change
   if (mGsmUmtsOptions != null) mGsmUmtsOptions.enableScreen();
 }
  @Override
  protected void onResume() {
    super.onResume();

    // upon resumption from the sub-activity, make sure we re-enable the
    // preferences.
    getPreferenceScreen().setEnabled(true);
    if (mGsmUmtsOptions != null) mGsmUmtsOptions.enableScreen();

    if (getPreferenceScreen().findPreference(BUTTON_PREFERED_NETWORK_MODE) != null) {
      mPhone.getPreferredNetworkType(
          mHandler.obtainMessage(MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
    }
  }