Update BT APIs for change in return type.
Change-Id: Ic85b47da50876fd6bdc6e223af4248a8586d82bc
This commit is contained in:
@@ -300,7 +300,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
LocalBluetoothProfileManager profileManager =
|
LocalBluetoothProfileManager profileManager =
|
||||||
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
|
||||||
CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager();
|
CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager();
|
||||||
Set<BluetoothDevice> devices = profileManager.getConnectedDevices();
|
List<BluetoothDevice> devices = profileManager.getConnectedDevices();
|
||||||
if (devices == null) return;
|
if (devices == null) return;
|
||||||
for (BluetoothDevice btDevice : devices) {
|
for (BluetoothDevice btDevice : devices) {
|
||||||
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
|
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
|
||||||
|
@@ -196,10 +196,9 @@ public class LocalBluetoothManager {
|
|||||||
|
|
||||||
// If we are playing music, don't scan unless forced.
|
// If we are playing music, don't scan unless forced.
|
||||||
if (mBluetoothA2dp != null) {
|
if (mBluetoothA2dp != null) {
|
||||||
Set<BluetoothDevice> sinks = mBluetoothA2dp.getConnectedDevices();
|
List<BluetoothDevice> sinks = mBluetoothA2dp.getConnectedDevices();
|
||||||
if (sinks.size() > 0) {
|
if (sinks.size() > 0) {
|
||||||
BluetoothDevice sink = sinks.toArray(new BluetoothDevice[sinks.size()])[0];
|
if (mBluetoothA2dp.isA2dpPlaying(sinks.get(0))) return;
|
||||||
if (mBluetoothA2dp.isA2dpPlaying(sink)) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -197,7 +197,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
mLocalManager = localManager;
|
mLocalManager = localManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Set<BluetoothDevice> getConnectedDevices();
|
public abstract List<BluetoothDevice> getConnectedDevices();
|
||||||
|
|
||||||
public abstract boolean connect(BluetoothDevice device);
|
public abstract boolean connect(BluetoothDevice device);
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
return mService.getDevicesMatchingConnectionStates(
|
return mService.getDevicesMatchingConnectionStates(
|
||||||
new int[] {BluetoothProfile.STATE_CONNECTED,
|
new int[] {BluetoothProfile.STATE_CONNECTED,
|
||||||
BluetoothProfile.STATE_CONNECTING,
|
BluetoothProfile.STATE_CONNECTING,
|
||||||
@@ -270,7 +270,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
Set<BluetoothDevice> sinks = getConnectedDevices();
|
List<BluetoothDevice> sinks = getConnectedDevices();
|
||||||
if (sinks != null) {
|
if (sinks != null) {
|
||||||
for (BluetoothDevice sink : sinks) {
|
for (BluetoothDevice sink : sinks) {
|
||||||
mService.disconnect(sink);
|
mService.disconnect(sink);
|
||||||
@@ -378,14 +378,11 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
* We just bound to the service, so refresh the UI of the
|
* We just bound to the service, so refresh the UI of the
|
||||||
* headset device.
|
* headset device.
|
||||||
*/
|
*/
|
||||||
Set<BluetoothDevice> deviceSet = mService.getConnectedDevices();
|
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
|
||||||
if (deviceSet.size() == 0) return;
|
if (deviceList.size() == 0) return;
|
||||||
|
|
||||||
BluetoothDevice[] devices =
|
|
||||||
deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
|
|
||||||
|
|
||||||
mLocalManager.getCachedDeviceManager()
|
mLocalManager.getCachedDeviceManager()
|
||||||
.onProfileStateChanged(devices[0], Profile.HEADSET,
|
.onProfileStateChanged(deviceList.get(0), Profile.HEADSET,
|
||||||
BluetoothProfile.STATE_CONNECTED);
|
BluetoothProfile.STATE_CONNECTED);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -415,7 +412,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
return mService.getConnectedDevices();
|
return mService.getConnectedDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,9 +423,8 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
Set<BluetoothDevice> deviceSet = getConnectedDevices();
|
List<BluetoothDevice> deviceList = getConnectedDevices();
|
||||||
BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
|
if (deviceList.size() != 0 && deviceList.get(0).equals(device)) {
|
||||||
if (devices.length != 0 && devices[0].equals(device)) {
|
|
||||||
// Downgrade prority as user is disconnecting the headset.
|
// Downgrade prority as user is disconnecting the headset.
|
||||||
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
|
||||||
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
|
||||||
@@ -441,10 +437,9 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getConnectionStatus(BluetoothDevice device) {
|
public int getConnectionStatus(BluetoothDevice device) {
|
||||||
Set<BluetoothDevice> deviceSet = getConnectedDevices();
|
List<BluetoothDevice> deviceList = getConnectedDevices();
|
||||||
BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
|
|
||||||
|
|
||||||
return devices.length > 0 && devices[0].equals(device)
|
return deviceList.size() > 0 && deviceList.get(0).equals(device)
|
||||||
? convertState(mService.getConnectionState(device))
|
? convertState(mService.getConnectionState(device))
|
||||||
: SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED;
|
: SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED;
|
||||||
}
|
}
|
||||||
@@ -506,7 +501,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,7 +600,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
return mService.getConnectedInputDevices();
|
return mService.getConnectedInputDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +698,7 @@ public abstract class LocalBluetoothProfileManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
return mService.getConnectedDevices();
|
return mService.getConnectedDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user