/** * Disconnects the given device and removes the associated BleManager object. * If the list of BleManagers is empty while the last activity unbinds from the service, * the service will stop itself. * @param device target device to disconnect and forget */ public void disconnect(final BluetoothDevice device) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); if (manager != null && manager.isConnected()) { manager.disconnect().enqueue(); } mManagedDevices.remove(device); }