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
This commit is contained in:
@@ -285,18 +285,8 @@
|
|||||||
<!-- Bluetooth settings. Message for disabling a profile of a bluetooth device. [CHAR LIMIT=NONE] -->
|
<!-- Bluetooth settings. Message for disabling a profile of a bluetooth device. [CHAR LIMIT=NONE] -->
|
||||||
<string name="bluetooth_disable_profile_message">This will disable:<br><b><xliff:g id="profile_name">%1$s</xliff:g></b><br><br>From:<br><b><xliff:g id="device_name">%2$s</xliff:g></b></string>
|
<string name="bluetooth_disable_profile_message">This will disable:<br><b><xliff:g id="profile_name">%1$s</xliff:g></b><br><br>From:<br><b><xliff:g id="device_name">%2$s</xliff:g></b></string>
|
||||||
|
|
||||||
<!-- Bluetooth settings. Message when connected to a device, except for phone audio. [CHAR LIMIT=40] -->
|
|
||||||
<string name="bluetooth_connected_no_headset">Connected (no phone)</string>
|
|
||||||
<!-- Bluetooth settings. Message when connected to a device, except for media audio. [CHAR LIMIT=40] -->
|
|
||||||
<string name="bluetooth_connected_no_a2dp">Connected (no media)</string>
|
|
||||||
<!-- Bluetooth settings. Message when connected to a device, except for map. [CHAR LIMIT=40] -->
|
|
||||||
<string name="bluetooth_connected_no_map">Connected (no message access)</string>
|
|
||||||
<!-- Bluetooth settings. Message when connected to a device, except for phone/media audio. [CHAR LIMIT=40] -->
|
|
||||||
<string name="bluetooth_connected_no_headset_no_a2dp">Connected (no phone or media)</string>
|
|
||||||
<!-- Bluetooth settings. Message when the device state is unknown -->
|
<!-- Bluetooth settings. Message when the device state is unknown -->
|
||||||
<string name="bluetooth_unknown" />
|
<string name="bluetooth_unknown" />
|
||||||
<!--Bluetooth settings screen, summary text under individual Bluetooth devices when pairing -->
|
|
||||||
<string name="bluetooth_pairing">Pairing\u2026</string>
|
|
||||||
<!--Bluetooth settings screen, summary text for Bluetooth device with no name -->
|
<!--Bluetooth settings screen, summary text for Bluetooth device with no name -->
|
||||||
<string name="bluetooth_device">Unnamed Bluetooth device</string>
|
<string name="bluetooth_device">Unnamed Bluetooth device</string>
|
||||||
<!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
|
<!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
|
||||||
|
@@ -112,7 +112,7 @@ public final class BluetoothDevicePreference extends Preference implements
|
|||||||
*/
|
*/
|
||||||
setTitle(mCachedDevice.getName());
|
setTitle(mCachedDevice.getName());
|
||||||
|
|
||||||
int summaryResId = getConnectionSummary();
|
int summaryResId = mCachedDevice.getConnectionSummary();
|
||||||
if (summaryResId != 0) {
|
if (summaryResId != 0) {
|
||||||
setSummary(summaryResId);
|
setSummary(summaryResId);
|
||||||
} else {
|
} 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() {
|
private int getBtClassDrawable() {
|
||||||
BluetoothClass btClass = mCachedDevice.getBtClass();
|
BluetoothClass btClass = mCachedDevice.getBtClass();
|
||||||
if (btClass != null) {
|
if (btClass != null) {
|
||||||
|
@@ -220,4 +220,6 @@ public abstract class DeviceListPreferenceFragment extends
|
|||||||
updateProgressUi(false);
|
updateProgressUi(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { }
|
||||||
}
|
}
|
||||||
|
@@ -937,6 +937,7 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
public void onBluetoothStateChanged(int bluetoothState) { }
|
public void onBluetoothStateChanged(int bluetoothState) { }
|
||||||
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { }
|
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { }
|
||||||
public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) { }
|
public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) { }
|
||||||
|
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanningStateChanged(boolean started) {
|
public void onScanningStateChanged(boolean started) {
|
||||||
|
Reference in New Issue
Block a user