use of android.bluetooth.BluetoothDevice in project XobotOS by xamarin.
the class BluetoothService method dumpInputDeviceProfile.
private void dumpInputDeviceProfile(PrintWriter pw) {
pw.println("\n--Bluetooth Service- Input Device Profile");
if (mInputDevice != null) {
List<BluetoothDevice> deviceList = mInputDevice.getConnectedDevices();
if (deviceList.size() == 0) {
pw.println("No input devices connected");
} else {
pw.println("Number of connected devices:" + deviceList.size());
BluetoothDevice device = deviceList.get(0);
pw.println("getConnectedDevices[0] = " + device);
pw.println("Priority of Connected device = " + mInputDevice.getPriority(device));
switch(mInputDevice.getConnectionState(device)) {
case BluetoothInputDevice.STATE_CONNECTING:
pw.println("getConnectionState() = STATE_CONNECTING");
break;
case BluetoothInputDevice.STATE_CONNECTED:
pw.println("getConnectionState() = STATE_CONNECTED");
break;
case BluetoothInputDevice.STATE_DISCONNECTING:
pw.println("getConnectionState() = STATE_DISCONNECTING");
break;
}
}
deviceList.clear();
deviceList = mInputDevice.getDevicesMatchingConnectionStates(new int[] { BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED });
pw.println("--Connected and Disconnected input devices");
for (BluetoothDevice device : deviceList) {
pw.println(device);
}
}
mAdapter.closeProfileProxy(BluetoothProfile.INPUT_DEVICE, mBluetoothHeadset);
}
use of android.bluetooth.BluetoothDevice in project XobotOS by xamarin.
the class BluetoothEventLoop method onNetworkDeviceDisconnected.
/**
* Called by native code on a DeviceDisconnected signal from
* org.bluez.NetworkServer.
*
* @param address the MAC address of the disconnected device
*/
private void onNetworkDeviceDisconnected(String address) {
BluetoothDevice device = mAdapter.getRemoteDevice(address);
mBluetoothService.handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED, BluetoothPan.LOCAL_NAP_ROLE);
}
use of android.bluetooth.BluetoothDevice in project XobotOS by xamarin.
the class BluetoothA2dpService method onBluetoothDisable.
private synchronized void onBluetoothDisable() {
if (!mAudioDevices.isEmpty()) {
BluetoothDevice[] devices = new BluetoothDevice[mAudioDevices.size()];
devices = mAudioDevices.keySet().toArray(devices);
for (BluetoothDevice device : devices) {
int state = getConnectionState(device);
switch(state) {
case BluetoothA2dp.STATE_CONNECTING:
case BluetoothA2dp.STATE_CONNECTED:
case BluetoothA2dp.STATE_PLAYING:
disconnectSinkNative(mBluetoothService.getObjectPathFromAddress(device.getAddress()));
handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTED);
break;
case BluetoothA2dp.STATE_DISCONNECTING:
handleSinkStateChange(device, BluetoothA2dp.STATE_DISCONNECTING, BluetoothA2dp.STATE_DISCONNECTED);
break;
}
}
mAudioDevices.clear();
}
mAudioManager.setParameters(BLUETOOTH_ENABLED + "=false");
}
use of android.bluetooth.BluetoothDevice in project XobotOS by xamarin.
the class BluetoothA2dpService method onConnectSinkResult.
/**
* Called by native code for the async response to a Connect
* method call to org.bluez.AudioSink.
*
* @param deviceObjectPath the object path for the connecting device
* @param result true on success; false on error
*/
private void onConnectSinkResult(String deviceObjectPath, boolean result) {
// when we a Sink Property Change
if (!result) {
if (deviceObjectPath != null) {
String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
if (address == null)
return;
BluetoothDevice device = mAdapter.getRemoteDevice(address);
int state = getConnectionState(device);
handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTED);
}
}
}
use of android.bluetooth.BluetoothDevice in project XobotOS by xamarin.
the class BluetoothA2dpService method onBluetoothEnable.
private synchronized void onBluetoothEnable() {
String devices = mBluetoothService.getProperty("Devices", true);
if (devices != null) {
String[] paths = devices.split(",");
for (String path : paths) {
String address = mBluetoothService.getAddressFromObjectPath(path);
BluetoothDevice device = mAdapter.getRemoteDevice(address);
ParcelUuid[] remoteUuids = mBluetoothService.getRemoteUuids(address);
if (remoteUuids != null)
if (BluetoothUuid.containsAnyUuid(remoteUuids, new ParcelUuid[] { BluetoothUuid.AudioSink, BluetoothUuid.AdvAudioDist })) {
addAudioSink(device);
}
}
}
mAudioManager.setParameters(BLUETOOTH_ENABLED + "=true");
mAudioManager.setParameters("A2dpSuspended=false");
}
Aggregations