fix: move `updateBleState` to connection page initialization (#3539)
What changed, and why it matters
This commit moves a Bluetooth status check so it runs when the device-connection screen first appears, rather than when the wallet view model is first created. It appears to be a timing or state-refresh bug fix for hardware wallet pairing, not a security vulnerability. There is no evidence in the commit of malicious behavior, exploitation, or a disclosed security issue.
No security action required. Treat as a normal functional bug fix. If Bluetooth permissions or state handling are security-sensitive for the product, consider reviewing whether `updateBleState()` requires permission checks before invocation.
Security signals we found
No security-relevant keywords in commit title or message
No input validation, authentication, or cryptographic changes
No memory safety, injection, or privilege escalation patterns
Change is a UI/VM lifecycle refactor for Bluetooth state
Evidence from the diff
The change relocates updateBleState() from the constructors of LedgerViewModelBase and TrezorConnectViewModelBase into ConnectDevicePageBodyState.initState() (guarded by hasBluetooth). This ensures Bluetooth state is queried when the connection page is initialized, likely avoiding stale or premature state during view model lifecycle. The diff is small (+2/-3) and contains no input handling, cryptographic, authorization, or network changes.
Changed components
lib/src/screens/connect_device/connect_device_page.dartlib/view_model/hardware_wallet/ledger_view_model.dartlib/view_model/hardware_wallet/trezor_connect_view_model.dartInspect captured patch +2 / −3
diff --git a/lib/src/screens/connect_device/connect_device_page.dart b/lib/src/screens/connect_device/connect_device_page.dart
index 2c08bd23..74691034 100644
--- a/lib/src/screens/connect_device/connect_device_page.dart
+++ b/lib/src/screens/connect_device/connect_device_page.dart
@@ -120,6 +120,8 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
}
if (widget.hardwareWalletVM.hasBluetooth) {
+ widget.hardwareWalletVM.updateBleState();
+
_longWaitTimer = Timer(const Duration(seconds: 10), () {
if (widget.hardwareWalletVM.isBleEnabled && bleDevices.isEmpty) {
setState(() => longWait = true);
diff --git a/lib/view_model/hardware_wallet/ledger_view_model.dart b/lib/view_model/hardware_wallet/ledger_view_model.dart
index f5efaa52..113ce51f 100644
--- a/lib/view_model/hardware_wallet/ledger_view_model.dart
+++ b/lib/view_model/hardware_wallet/ledger_view_model.dart
@@ -42,8 +42,6 @@ abstract class LedgerViewModelBase extends HardwareWalletViewModel with Store {
}
});
- updateBleState();
-
if (!Platform.isIOS) {
ledgerPlusUSB = sdk.LedgerInterface.usb();
}
diff --git a/lib/view_model/hardware_wallet/trezor_connect_view_model.dart b/lib/view_model/hardware_wallet/trezor_connect_view_model.dart
index 28116e3c..4d65e4d5 100644
--- a/lib/view_model/hardware_wallet/trezor_connect_view_model.dart
+++ b/lib/view_model/hardware_wallet/trezor_connect_view_model.dart
@@ -39,7 +39,6 @@ abstract class TrezorConnectViewModelBase extends HardwareWalletViewModel with S
_initBLE();
}
});
- updateBleState();
if (!Platform.isIOS) {
trezorUSB = sdk.TrezorInterface.usb();
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.