Advertise the Bluetooth address if the device is discoverable.

This commit is contained in:
akwizgran
2011-11-08 21:12:08 +00:00
parent b1d08af5a2
commit 7d09102c4d

View File

@@ -146,11 +146,14 @@ class BluetoothPlugin extends AbstractPlugin implements StreamPlugin {
// Try to make the device discoverable (requires root on Linux)
try {
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
} catch(BluetoothStateException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
}
// Advertise the address to contacts if the device is discoverable
if(localDevice.getDiscoverable() == DiscoveryAgent.GIAC) {
TransportProperties p = callback.getLocalProperties();
p.put("address", localDevice.getBluetoothAddress());
callback.setLocalProperties(p);
} catch(BluetoothStateException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
}
}