mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-27 06:18:50 +01:00
Add thread-safety and BLE support for Ledger and Trezor devices (#3638)
* feat: support BLE device detection for Ledger and Trezor wallets, update trezor-flutter dependency * feat: add BLE connection state listener for Trezor devices, handle disconnect events, and clean up resources on close * feat: add mutex locking to MoneroTrezorService for thread-safe operations
This commit is contained in:
@@ -108,6 +108,8 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadConnectedDevices();
|
||||
|
||||
_bleStateTimer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => widget.hardwareWalletVM.updateBleState(),
|
||||
@@ -131,6 +133,23 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadConnectedDevices() async {
|
||||
try {
|
||||
final connected = await widget.hardwareWalletVM.getConnectedBleDevices();
|
||||
|
||||
printV(connected);
|
||||
if (!mounted || connected.isEmpty) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
bleDevices.addAll(connected);
|
||||
longWait = false;
|
||||
});
|
||||
} catch (e) {
|
||||
printV(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bleRefreshTimer?.cancel();
|
||||
|
||||
Reference in New Issue
Block a user