Loading src/com/android/settings/TetherSettings.java +36 −26 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.webkit.WebView; import java.io.InputStream; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicReference; import java.util.Locale; /* Loading Loading @@ -78,7 +79,7 @@ public class TetherSettings extends SettingsPreferenceFragment private String[] mWifiRegexs; private String[] mBluetoothRegexs; private BluetoothPan mBluetoothPan; private AtomicReference<BluetoothPan> mBluetoothPan; private static final String WIFI_AP_SSID_AND_SECURITY = "wifi_ap_ssid_and_security"; private static final int CONFIG_SUBTEXT = R.string.wifi_tether_configure_subtext; Loading Loading @@ -151,7 +152,8 @@ public class TetherSettings extends SettingsPreferenceFragment if (!bluetoothAvailable) { getPreferenceScreen().removePreference(mBluetoothTether); } else { if (mBluetoothPan != null && mBluetoothPan.isTetheringOn()) { BluetoothPan pan = mBluetoothPan.get(); if (pan != null && pan.isTetheringOn()) { mBluetoothTether.setChecked(true); } else { mBluetoothTether.setChecked(false); Loading Loading @@ -188,10 +190,10 @@ public class TetherSettings extends SettingsPreferenceFragment private BluetoothProfile.ServiceListener mProfileServiceListener = new BluetoothProfile.ServiceListener() { public void onServiceConnected(int profile, BluetoothProfile proxy) { mBluetoothPan = (BluetoothPan) proxy; mBluetoothPan.set((BluetoothPan) proxy); } public void onServiceDisconnected(int profile) { mBluetoothPan = null; mBluetoothPan.set(null); } }; Loading Loading @@ -235,8 +237,9 @@ public class TetherSettings extends SettingsPreferenceFragment switch (intent .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) { case BluetoothAdapter.STATE_ON: if(mBluetoothPan != null) { mBluetoothPan.setBluetoothTethering(true); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) { bluetoothPan.setBluetoothTethering(true); mBluetoothEnableForTether = false; } break; Loading Loading @@ -389,17 +392,21 @@ public class TetherSettings extends SettingsPreferenceFragment } else if (btState == BluetoothAdapter.STATE_TURNING_ON) { mBluetoothTether.setEnabled(false); mBluetoothTether.setSummary(R.string.bluetooth_turning_on); } else if (btState == BluetoothAdapter.STATE_ON && mBluetoothPan != null && mBluetoothPan.isTetheringOn()) { } else { BluetoothPan bluetoothPan = mBluetoothPan.get(); if (btState == BluetoothAdapter.STATE_ON && bluetoothPan != null && bluetoothPan.isTetheringOn()) { mBluetoothTether.setChecked(true); mBluetoothTether.setEnabled(true); int bluetoothTethered = mBluetoothPan.getConnectedDevices().size(); int bluetoothTethered = bluetoothPan.getConnectedDevices().size(); if (bluetoothTethered > 1) { String summary = getString( R.string.bluetooth_tethering_devices_connected_subtext, bluetoothTethered); R.string.bluetooth_tethering_devices_connected_subtext, bluetoothTethered); mBluetoothTether.setSummary(summary); } else if (bluetoothTethered == 1) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_device_connected_subtext); mBluetoothTether.setSummary( R.string.bluetooth_tethering_device_connected_subtext); } else if (bluetoothErrored) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext); } else { Loading @@ -411,6 +418,7 @@ public class TetherSettings extends SettingsPreferenceFragment mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext); } } } public boolean onPreferenceChange(Preference preference, Object value) { boolean enable = (Boolean) value; Loading Loading @@ -476,7 +484,8 @@ public class TetherSettings extends SettingsPreferenceFragment mBluetoothTether.setSummary(R.string.bluetooth_turning_on); mBluetoothTether.setEnabled(false); } else { mBluetoothPan.setBluetoothTethering(true); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) bluetoothPan.setBluetoothTethering(true); mBluetoothTether.setSummary(R.string.bluetooth_tethering_available_subtext); } break; Loading Loading @@ -528,7 +537,8 @@ public class TetherSettings extends SettingsPreferenceFragment errored = true; } mBluetoothPan.setBluetoothTethering(false); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) bluetoothPan.setBluetoothTethering(false); if (errored) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext); } else { Loading Loading
src/com/android/settings/TetherSettings.java +36 −26 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.webkit.WebView; import java.io.InputStream; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicReference; import java.util.Locale; /* Loading Loading @@ -78,7 +79,7 @@ public class TetherSettings extends SettingsPreferenceFragment private String[] mWifiRegexs; private String[] mBluetoothRegexs; private BluetoothPan mBluetoothPan; private AtomicReference<BluetoothPan> mBluetoothPan; private static final String WIFI_AP_SSID_AND_SECURITY = "wifi_ap_ssid_and_security"; private static final int CONFIG_SUBTEXT = R.string.wifi_tether_configure_subtext; Loading Loading @@ -151,7 +152,8 @@ public class TetherSettings extends SettingsPreferenceFragment if (!bluetoothAvailable) { getPreferenceScreen().removePreference(mBluetoothTether); } else { if (mBluetoothPan != null && mBluetoothPan.isTetheringOn()) { BluetoothPan pan = mBluetoothPan.get(); if (pan != null && pan.isTetheringOn()) { mBluetoothTether.setChecked(true); } else { mBluetoothTether.setChecked(false); Loading Loading @@ -188,10 +190,10 @@ public class TetherSettings extends SettingsPreferenceFragment private BluetoothProfile.ServiceListener mProfileServiceListener = new BluetoothProfile.ServiceListener() { public void onServiceConnected(int profile, BluetoothProfile proxy) { mBluetoothPan = (BluetoothPan) proxy; mBluetoothPan.set((BluetoothPan) proxy); } public void onServiceDisconnected(int profile) { mBluetoothPan = null; mBluetoothPan.set(null); } }; Loading Loading @@ -235,8 +237,9 @@ public class TetherSettings extends SettingsPreferenceFragment switch (intent .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) { case BluetoothAdapter.STATE_ON: if(mBluetoothPan != null) { mBluetoothPan.setBluetoothTethering(true); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) { bluetoothPan.setBluetoothTethering(true); mBluetoothEnableForTether = false; } break; Loading Loading @@ -389,17 +392,21 @@ public class TetherSettings extends SettingsPreferenceFragment } else if (btState == BluetoothAdapter.STATE_TURNING_ON) { mBluetoothTether.setEnabled(false); mBluetoothTether.setSummary(R.string.bluetooth_turning_on); } else if (btState == BluetoothAdapter.STATE_ON && mBluetoothPan != null && mBluetoothPan.isTetheringOn()) { } else { BluetoothPan bluetoothPan = mBluetoothPan.get(); if (btState == BluetoothAdapter.STATE_ON && bluetoothPan != null && bluetoothPan.isTetheringOn()) { mBluetoothTether.setChecked(true); mBluetoothTether.setEnabled(true); int bluetoothTethered = mBluetoothPan.getConnectedDevices().size(); int bluetoothTethered = bluetoothPan.getConnectedDevices().size(); if (bluetoothTethered > 1) { String summary = getString( R.string.bluetooth_tethering_devices_connected_subtext, bluetoothTethered); R.string.bluetooth_tethering_devices_connected_subtext, bluetoothTethered); mBluetoothTether.setSummary(summary); } else if (bluetoothTethered == 1) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_device_connected_subtext); mBluetoothTether.setSummary( R.string.bluetooth_tethering_device_connected_subtext); } else if (bluetoothErrored) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext); } else { Loading @@ -411,6 +418,7 @@ public class TetherSettings extends SettingsPreferenceFragment mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext); } } } public boolean onPreferenceChange(Preference preference, Object value) { boolean enable = (Boolean) value; Loading Loading @@ -476,7 +484,8 @@ public class TetherSettings extends SettingsPreferenceFragment mBluetoothTether.setSummary(R.string.bluetooth_turning_on); mBluetoothTether.setEnabled(false); } else { mBluetoothPan.setBluetoothTethering(true); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) bluetoothPan.setBluetoothTethering(true); mBluetoothTether.setSummary(R.string.bluetooth_tethering_available_subtext); } break; Loading Loading @@ -528,7 +537,8 @@ public class TetherSettings extends SettingsPreferenceFragment errored = true; } mBluetoothPan.setBluetoothTethering(false); BluetoothPan bluetoothPan = mBluetoothPan.get(); if (bluetoothPan != null) bluetoothPan.setBluetoothTethering(false); if (errored) { mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext); } else { Loading