diff options
-rw-r--r-- | java/direct_bt/tinyb/DBTAdapter.java | 46 | ||||
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 42 | ||||
-rw-r--r-- | java/direct_bt/tinyb/DBTManager.java | 2 |
3 files changed, 34 insertions, 56 deletions
diff --git a/java/direct_bt/tinyb/DBTAdapter.java b/java/direct_bt/tinyb/DBTAdapter.java index 46879a67..2580172f 100644 --- a/java/direct_bt/tinyb/DBTAdapter.java +++ b/java/direct_bt/tinyb/DBTAdapter.java @@ -87,41 +87,25 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter @Override public synchronized void close() { - close(false); - } - - /* pp */ synchronized void close(final boolean isShutdown) { if( !isValid() ) { return; } - if( !isShutdown ) { // avoid all interaction @ JVM shutdown, native dtor (deleteImpl) cleans up. - - // mute all listener first - removeAllStatusListener(); - disableDiscoverableNotifications(); - disableDiscoveringNotifications(); - disablePairableNotifications(); - disablePoweredNotifications(); - - stopDiscovery(); - - final List<BluetoothDevice> devices = getDevices(); - for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext(); ) { - final DBTDevice d = (DBTDevice) id.next(); - d.close( false ); - } - - // done in native dtor: removeDevicesImpl(); - - } else { - - final List<BluetoothDevice> devices = getDevices(); - for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext(); ) { - final DBTDevice d = (DBTDevice) id.next(); - d.close( true ); - } - + // mute all listener first + removeAllStatusListener(); + disableDiscoverableNotifications(); + disableDiscoveringNotifications(); + disablePairableNotifications(); + disablePoweredNotifications(); + + stopDiscovery(); + + final List<BluetoothDevice> devices = getDevices(); + for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext(); ) { + final DBTDevice d = (DBTDevice) id.next(); + d.close(); } + + // done in native dtor: removeDevicesImpl(); discoveredDevices.clear(); super.close(); diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java index fa47a6ff..6b1bdd0e 100644 --- a/java/direct_bt/tinyb/DBTDevice.java +++ b/java/direct_bt/tinyb/DBTDevice.java @@ -233,37 +233,31 @@ public class DBTDevice extends DBTObject implements BluetoothDevice @Override public synchronized void close() { - close(false); - } - - /* pp */ synchronized void close(final boolean isShutdown) { if( !isValid() ) { return; } - if( !isShutdown ) { // avoid all interaction @ JVM shutdown, native dtor (deleteImpl) cleans up. - // implicit via disconnect, gatt.disconnect(): GATTHandler::removeAllCharacteristicListener(); - disconnectImpl(); // make sure, regardless of isConnected state + // GATTHandler::removeAllCharacteristicListener(): implicit via device.disconnect -> gatt.disconnect + disconnectImpl(); // make sure, regardless of isConnected state - disableConnectedNotifications(); - disableRSSINotifications(); - disableManufacturerDataNotifications(); - disableServicesResolvedNotifications(); + disableConnectedNotifications(); + disableRSSINotifications(); + disableManufacturerDataNotifications(); + disableServicesResolvedNotifications(); - disableBlockedNotifications(); - disableBlockedNotificationsImpl(); - disablePairedNotifications(); - disablePairedNotificationsImpl(); - disableServiceDataNotifications(); - disableTrustedNotifications(); - // FIXME disableTrustedNotificationsImpl(); + disableBlockedNotifications(); + disableBlockedNotificationsImpl(); + disablePairedNotifications(); + disablePairedNotificationsImpl(); + disableServiceDataNotifications(); + disableTrustedNotifications(); + // FIXME disableTrustedNotificationsImpl(); - clearServiceCache(); + clearServiceCache(); - final DBTAdapter a = getAdapter(); - if( null != a ) { - a.removeStatusListener(statusListener); - a.removeDiscoveredDevice(this); - } + final DBTAdapter a = getAdapter(); + if( null != a ) { + a.removeStatusListener(statusListener); + a.removeDiscoveredDevice(this); } super.close(); } diff --git a/java/direct_bt/tinyb/DBTManager.java b/java/direct_bt/tinyb/DBTManager.java index 45faed64..d4dcd70f 100644 --- a/java/direct_bt/tinyb/DBTManager.java +++ b/java/direct_bt/tinyb/DBTManager.java @@ -316,7 +316,7 @@ public class DBTManager implements BluetoothManager public void shutdown() { for(final Iterator<BluetoothAdapter> ia= adapters.iterator(); ia.hasNext(); ) { final DBTAdapter a = (DBTAdapter)ia.next(); - a.close( true ); + a.close(); } adapters.clear(); deleteImpl(nativeInstance); |