Skip to content

Commit

Permalink
fix(react-native-usb): close all opened devices without exception
Browse files Browse the repository at this point in the history
  • Loading branch information
yanascz committed Aug 23, 2024
1 parent dd6281c commit a057422
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ class ReactNativeUsbModule : Module() {

private fun closeDevice(deviceName: String) {
Log.d(LOG_TAG, "Closing device $deviceName")
val usbConnection = getOpenedConnection(deviceName)
usbConnection.close()
getOpenedConnection(deviceName).close()
openedConnections.remove(deviceName)
}

private fun closeAllOpenedDevices() {
Log.d(LOG_TAG, "Closing all devices")
openedConnections.forEach { (deviceName, _) ->
closeDevice(deviceName)
with(openedConnections.iterator()) {
forEach {
it.value.close()
remove()
}
}
}

Expand Down

0 comments on commit a057422

Please sign in to comment.