diff options
author | Jake Hamby <jhamby@google.com> | 2012-10-08 12:13:14 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-08 12:13:14 -0700 |
commit | 283dce21b4902b1d0fa77c26f37f885203647d3a (patch) | |
tree | f290cf2c75873aa142410d204e27ade81c5cc44d /src/com/android/settings | |
parent | c3ebad20f24299a680caa4ab70e22e9042df405e (diff) | |
parent | 904d3726d4f72178d3df77da398ab055c66577fd (diff) | |
download | packages_apps_Settings-283dce21b4902b1d0fa77c26f37f885203647d3a.zip packages_apps_Settings-283dce21b4902b1d0fa77c26f37f885203647d3a.tar.gz packages_apps_Settings-283dce21b4902b1d0fa77c26f37f885203647d3a.tar.bz2 |
Merge "Allow disconnected BT profiles to be unchecked in Settings." into jb-mr1-dev
Diffstat (limited to 'src/com/android/settings')
-rwxr-xr-x | src/com/android/settings/bluetooth/DeviceProfilesSettings.java | 18 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/PanProfile.java | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java index 67d2258..335d888 100755 --- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java +++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java @@ -241,7 +241,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment mCachedDevice.setName((String) newValue); } else if (preference instanceof CheckBoxPreference) { LocalBluetoothProfile prof = getProfileOf(preference); - onProfileClicked(prof); + onProfileClicked(prof, (CheckBoxPreference) preference); return false; // checkbox will update from onDeviceAttributesChanged() callback } else { return false; @@ -250,7 +250,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment return true; } - private void onProfileClicked(LocalBluetoothProfile profile) { + private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) { BluetoothDevice device = mCachedDevice.getDevice(); int status = profile.getConnectionStatus(device); @@ -260,8 +260,14 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment if (isConnected) { askDisconnect(getActivity(), profile); } else { - profile.setPreferred(device, true); - mCachedDevice.connectProfile(profile); + if (profile.isPreferred(device)) { + // profile is preferred but not connected: disable auto-connect + profile.setPreferred(device, false); + refreshProfilePreference(profilePref, profile); + } else { + profile.setPreferred(device, true); + mCachedDevice.connectProfile(profile); + } } } @@ -357,8 +363,4 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment private void unpairDevice() { mCachedDevice.unpair(); } - - private boolean getAutoConnect(LocalBluetoothProfile prof) { - return prof.isPreferred(mCachedDevice.getDevice()); - } } diff --git a/src/com/android/settings/bluetooth/PanProfile.java b/src/com/android/settings/bluetooth/PanProfile.java index b9db77b..f6e0691 100755 --- a/src/com/android/settings/bluetooth/PanProfile.java +++ b/src/com/android/settings/bluetooth/PanProfile.java @@ -106,7 +106,8 @@ final class PanProfile implements LocalBluetoothProfile { } public boolean isPreferred(BluetoothDevice device) { - return true; + // return current connection status so profile checkbox is set correctly + return getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED; } public int getPreferred(BluetoothDevice device) { |