Skip to content

Commit 4bfbb78

Browse files
committed
fix: report trezor close timeout
1 parent 2ca54d7 commit 4bfbb78

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

app/src/main/java/to/bitkit/services/TrezorTransport.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ class TrezorTransport @Inject constructor(
894894
connection.gatt.disconnect()
895895

896896
val disconnected = disconnectLatch.await(DISCONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
897+
val timeoutError = if (disconnected) null else "BLE disconnect timed out; forced close"
897898
if (!disconnected) {
898899
Logger.warn("BLE disconnect timeout, forcing close: '$path'", context = TAG)
899900
}
@@ -902,7 +903,7 @@ class TrezorTransport @Inject constructor(
902903
connection.gatt.close()
903904
Thread.sleep(100)
904905
Logger.info("BLE device closed: '$path'", context = TAG)
905-
TrezorTransportWriteResult(success = true, error = "")
906+
TrezorTransportWriteResult(success = timeoutError == null, error = timeoutError.orEmpty())
906907
} catch (e: Exception) {
907908
Logger.error("BLE close failed", e, context = TAG)
908909
TrezorTransportWriteResult(success = false, error = e.message ?: "BLE close failed")

0 commit comments

Comments
 (0)