aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/direct_bt/tinyb/DBTAdapter.java12
-rw-r--r--java/org/tinyb/BluetoothAdapter.java6
2 files changed, 17 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);
diff --git a/java/org/tinyb/BluetoothAdapter.java b/java/org/tinyb/BluetoothAdapter.java
index c7b19e81..34945357 100644
--- a/java/org/tinyb/BluetoothAdapter.java
+++ b/java/org/tinyb/BluetoothAdapter.java
@@ -352,6 +352,12 @@ public interface BluetoothAdapter extends BluetoothObject
/**
* Add the given {@link AdapterStatusListener} to the list if not already present.
+ * <p>
+ * The newly added {@link AdapterStatusListener} will receive an initial
+ * {@link AdapterStatusListener#adapterSettingsChanged(BluetoothAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged}
+ * event, passing an {@link AdapterSettings empty oldMask} and {@link AdapterSettings current newMask}. <br>
+ * This allows the receiver to be aware of this adapter's current settings.
+ * </p>
* @param listener A {@link AdapterStatusListener} instance
* @param deviceMatch Optional {@link BluetoothDevice} to be matched before calling any
* {@link AdapterStatusListener} {@code device*} methods. Pass {@code null} for no filtering.