From 88643ac6baeb2079e4a6f3fd11ca74e84573da4e Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Wed, 4 Feb 2015 12:54:50 -0500 Subject: [PATCH] Support some changes to SettingsLib SettingsLib has a couple of bluetooth changes to support quick settings and as a result a few updates are needed in Settings. Depends on I7f828f0038ad0cf39274986ece6d486d545f0286 Change-Id: I9b207b74abb0175148fd4a3c421d33ab9a861587 --- res/values/strings.xml | 10 ---- .../bluetooth/BluetoothDevicePreference.java | 56 +------------------ .../DeviceListPreferenceFragment.java | 2 + .../settings/bluetooth/DockService.java | 1 + 4 files changed, 4 insertions(+), 65 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 382e3b64a49..914139446dd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -285,18 +285,8 @@ This will disable:<br><b>%1$s</b><br><br>From:<br><b>%2$s</b> - - Connected (no phone) - - Connected (no media) - - Connected (no message access) - - Connected (no phone or media) - - Pairing\u2026 Unnamed Bluetooth device diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java index 67c026b30cf..0bb54b2fdbb 100644 --- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java @@ -112,7 +112,7 @@ public final class BluetoothDevicePreference extends Preference implements */ setTitle(mCachedDevice.getName()); - int summaryResId = getConnectionSummary(); + int summaryResId = mCachedDevice.getConnectionSummary(); if (summaryResId != 0) { setSummary(summaryResId); } else { @@ -232,60 +232,6 @@ public final class BluetoothDevicePreference extends Preference implements } } - private int getConnectionSummary() { - final CachedBluetoothDevice cachedDevice = mCachedDevice; - - boolean profileConnected = false; // at least one profile is connected - boolean a2dpNotConnected = false; // A2DP is preferred but not connected - boolean headsetNotConnected = false; // Headset is preferred but not connected - - for (LocalBluetoothProfile profile : cachedDevice.getProfiles()) { - int connectionStatus = cachedDevice.getProfileConnectionState(profile); - - switch (connectionStatus) { - case BluetoothProfile.STATE_CONNECTING: - case BluetoothProfile.STATE_DISCONNECTING: - return Utils.getConnectionStateSummary(connectionStatus); - - case BluetoothProfile.STATE_CONNECTED: - profileConnected = true; - break; - - case BluetoothProfile.STATE_DISCONNECTED: - if (profile.isProfileReady()) { - if (profile instanceof A2dpProfile) { - a2dpNotConnected = true; - } else if (profile instanceof HeadsetProfile) { - headsetNotConnected = true; - } - } - break; - } - } - - if (profileConnected) { - if (a2dpNotConnected && headsetNotConnected) { - return R.string.bluetooth_connected_no_headset_no_a2dp; - } else if (a2dpNotConnected) { - return R.string.bluetooth_connected_no_a2dp; - } else if (headsetNotConnected) { - return R.string.bluetooth_connected_no_headset; - } else { - return R.string.bluetooth_connected; - } - } - - switch (cachedDevice.getBondState()) { - case BluetoothDevice.BOND_BONDING: - return R.string.bluetooth_pairing; - - case BluetoothDevice.BOND_BONDED: - case BluetoothDevice.BOND_NONE: - default: - return 0; - } - } - private int getBtClassDrawable() { BluetoothClass btClass = mCachedDevice.getBtClass(); if (btClass != null) { diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java index b2a703dfe88..f07a9f2ffb6 100644 --- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java +++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java @@ -220,4 +220,6 @@ public abstract class DeviceListPreferenceFragment extends updateProgressUi(false); } } + + public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { } } diff --git a/src/com/android/settings/bluetooth/DockService.java b/src/com/android/settings/bluetooth/DockService.java index c4f6485a50f..020ca0c8a6b 100644 --- a/src/com/android/settings/bluetooth/DockService.java +++ b/src/com/android/settings/bluetooth/DockService.java @@ -937,6 +937,7 @@ public final class DockService extends Service implements ServiceListener { public void onBluetoothStateChanged(int bluetoothState) { } public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { } public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) { } + public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { } @Override public void onScanningStateChanged(boolean started) {