コード例 #1
0
 /*
  * M: update ipv4&ipv6 setting preference
  */
 private void updateIpv6Preference() {
   if (mTetherIpv6 != null) {
     mTetherIpv6.setEnabled(
         !mUsbTether.isChecked() && !mBluetoothTether.isChecked() && !mWifiTether.isChecked());
     ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
     if (cm != null) {
       int ipv6Value = cm.getTetheringIpv6Enable() ? 1 : 0;
       mTetherIpv6.setValueIndex(ipv6Value);
       mTetherIpv6.setSummary(
           getResources().getStringArray(R.array.tethered_ipv6_entries)[ipv6Value]);
     }
   }
 }
コード例 #2
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.tether_prefs);

    /// M: get plugin
    mExt = Utils.getApnSettingsPlugin(getActivity());

    final Activity activity = getActivity();
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null) {
      adapter.getProfileProxy(
          activity.getApplicationContext(), mProfileServiceListener, BluetoothProfile.PAN);
    }
    /// M: @{
    mBluetoothDunProxy =
        new BluetoothDun(getActivity().getApplicationContext(), mDunServiceListener);
    mWifiTether = (HotspotSwitchPreference) findPreference(WIFI_SWITCH_SETTINGS);
    mWifiTether.setChecked(false);
    /// @}

    mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS);
    mBluetoothTether = (CheckBoxPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);

    mTetherIpv6 = (ListPreference) findPreference(TETHERED_IPV6);
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    /// M: @{
    mUsbTetherType = (ListPreference) findPreference(USB_TETHERING_TYPE);
    if (!FeatureOption.MTK_TETHERING_EEM_SUPPORT) {
      getPreferenceScreen().removePreference(mUsbTetherType);
    }

    /// @}
    mUsbRegexs = cm.getTetherableUsbRegexs();
    mWifiRegexs = cm.getTetherableWifiRegexs();
    mBluetoothRegexs = cm.getTetherableBluetoothRegexs();

    final boolean usbAvailable = mUsbRegexs.length != 0;
    final boolean wifiAvailable = mWifiRegexs.length != 0;
    final boolean bluetoothAvailable = mBluetoothRegexs.length != 0;

    if (!usbAvailable || Utils.isMonkeyRunning()) {
      getPreferenceScreen().removePreference(mUsbTether);
      getPreferenceScreen().removePreference(mUsbTetherType);
    }

    if (wifiAvailable && !Utils.isMonkeyRunning()) {
      mWifiApEnabler = new WifiApEnabler(activity, mWifiTether);
      mWifiApEnabler.setTetherSettings(this);
    } else {
      getPreferenceScreen().removePreference(mWifiTether);
    }

    if (!bluetoothAvailable) {
      getPreferenceScreen().removePreference(mBluetoothTether);
    } else {
      BluetoothPan pan = mBluetoothPan.get();
      /// M:
      BluetoothDun dun = BluetoothDunGetProxy();
      if ((pan != null && pan.isTetheringOn()) || (dun != null && dun.isTetheringOn())) {
        mBluetoothTether.setChecked(true);
      } else {
        mBluetoothTether.setChecked(false);
      }
    }

    /// M: add tether apn settings
    mExt.customizeTetherApnSettings(getPreferenceScreen());

    mProvisionApp =
        getResources()
            .getStringArray(com.android.internal.R.array.config_mobile_hotspot_provision_app);

    mView = new WebView(activity);

    /// M: @{
    if (FeatureOption.MTK_TETHERINGIPV6_SUPPORT) {
      if (mTetherIpv6 != null) {
        mTetherIpv6.setOnPreferenceChangeListener(this);
      }
    } else {
      getPreferenceScreen().removePreference(mTetherIpv6);
    }
    getMountService();
    /// @}
  }