diff options
author | Jake Hamby <jhamby@google.com> | 2012-10-04 17:42:38 -0700 |
---|---|---|
committer | Jake Hamby <jhamby@google.com> | 2012-10-04 17:42:38 -0700 |
commit | 904d3726d4f72178d3df77da398ab055c66577fd (patch) | |
tree | 0a5c18e7d8430df178befe696970417f5123fca6 | |
parent | 27636444a4be011a6a813cba6429e58629316ce4 (diff) | |
download | packages_apps_settings-904d3726d4f72178d3df77da398ab055c66577fd.zip packages_apps_settings-904d3726d4f72178d3df77da398ab055c66577fd.tar.gz packages_apps_settings-904d3726d4f72178d3df77da398ab055c66577fd.tar.bz2 |
Allow disconnected BT profiles to be unchecked in Settings.
In the Bluetooth profile list, the checkbox indicates whether the
profile is preferred (we should auto connect). If the profile is
not connected, selecting it will try to connect the profile and set
it to preferred. If the profile can't be connected, then the user
could not turn off the preferred setting for the profile.
Change the behavior so that when a profile is not connected,
but is marked as preferred, selecting the profile will turn off the
preferred setting (no auto connect) instead of trying to connect.
This enables the user to turn off auto connect for a profile when
it can't be connected. Tapping a second time will try to connect
the profile and set it as preferred, as usual.
Also change PanProfile to return the current connection status for
isPreferred() instead of always returning true. Currently, the
PAN profile is always checked, which is confusing because it looks
like PAN is always connected. Also, because of the new behavior
when a profile is selected, it's now necessary to return false for
isPreferred() when PAN isn't connected, so that we will try to
connect when the user selects it, instead of trying to turn off
the preferred setting, which isn't supported for PAN.
Bug: 7007641
Change-Id: Ifb0f51a15379bc254933168c43bdfc8b22f26051
-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) { |