Don't store the local address unless the device is discoverable.

This commit is contained in:
akwizgran
2011-10-28 13:16:00 +01:00
parent 40689b7e6e
commit 70c5d7ce75

View File

@@ -120,7 +120,6 @@ class BluetoothPlugin extends AbstractPlugin implements StreamPlugin {
return;
}
socket = scn;
setLocalBluetoothAddress(localDevice.getBluetoothAddress());
}
startContactAccepterThread();
}
@@ -145,18 +144,14 @@ class BluetoothPlugin extends AbstractPlugin implements StreamPlugin {
// Try to make the device discoverable (requires root on Linux)
try {
localDevice.setDiscoverable(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());
}
}
private synchronized void setLocalBluetoothAddress(String address) {
assert started;
TransportProperties p = callback.getLocalProperties();
p.put("address", address);
callback.setLocalProperties(p);
}
private void startContactAccepterThread() {
new Thread() {
@Override