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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user