diff options
Diffstat (limited to 'java/direct_bt/tinyb/DBTAdapter.java')
-rw-r--r-- | java/direct_bt/tinyb/DBTAdapter.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/java/direct_bt/tinyb/DBTAdapter.java b/java/direct_bt/tinyb/DBTAdapter.java index 717fd697..c9725fd7 100644 --- a/java/direct_bt/tinyb/DBTAdapter.java +++ b/java/direct_bt/tinyb/DBTAdapter.java @@ -106,11 +106,18 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter } // done in native dtor: removeDevicesImpl(); - discoveredDevices.clear(); + + poweredOff(); super.close(); } + private final void poweredOff() { + isPowered.set(false); + isDiscovering.set(false); + discoveredDevices.clear(); + } + @Override public boolean equals(final Object obj) { @@ -413,6 +420,9 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter if( changedmask.isSet(AdapterSettings.SettingType.POWERED) ) { final boolean _isPowered = newmask.isSet(AdapterSettings.SettingType.POWERED); if( isPowered.compareAndSet(!_isPowered, _isPowered) ) { + if( !_isPowered ) { + poweredOff(); + } synchronized(userCallbackLock) { if( null != userPoweredNotificationCB ) { userPoweredNotificationCB.run(_isPowered); |