fix: skip Dart-side reconnect polling after manual disconnect#5915
fix: skip Dart-side reconnect polling after manual disconnect#5915
Conversation
When the user disconnects from Device Info page, set _manualDisconnect flag so onDeviceDisconnected skips periodicConnect and cancels the reconnection timer.
Greptile SummaryThis PR introduces a Key issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant DeviceInfoPage
participant DeviceProvider
participant BLELayer
participant NativeLayer
Note over User,NativeLayer: Manual Disconnect Flow (new behavior)
User->>DeviceInfoPage: Tap Disconnect
DeviceInfoPage->>DeviceProvider: _bleDisconnectDevice(device)
DeviceProvider->>DeviceProvider: _manualDisconnect = true
DeviceProvider->>BLELayer: ensureConnection()
BLELayer-->>DeviceProvider: connection
DeviceProvider->>BLELayer: connection.disconnect()
BLELayer-->>DeviceProvider: onDeviceConnectionStateChanged(disconnected)
DeviceProvider->>DeviceProvider: onDeviceDisconnected()
DeviceProvider->>DeviceProvider: _disconnectNotificationTimer starts ⚠️
DeviceProvider->>DeviceProvider: _manualDisconnect == true → reset, cancel timer, return
Note over DeviceProvider: periodicConnect() NOT called ✓
Note over User,NativeLayer: Organic Disconnect Flow (unchanged)
BLELayer-->>DeviceProvider: onDeviceConnectionStateChanged(disconnected)
DeviceProvider->>DeviceProvider: onDeviceDisconnected()
DeviceProvider->>DeviceProvider: _manualDisconnect == false → continue
DeviceProvider->>DeviceProvider: Future.delayed(1s) → periodicConnect()
DeviceProvider->>NativeLayer: ensureConnection / scan
|
Summary
When the user manually disconnects from the Device Info page,
onDeviceDisconnectedcallsperiodicConnectafter 1 second.periodicConnectcallsensureConnection, but since the device was unpaired, there's no paired device ID — so it falls through to_startPollingReconnect, triggering a 15-second scan timer that keeps searching for a device to connect to. This is unnecessary because:autoConnect=truewith unlimited retries, iOS:centralManager.connect()chipset-level reconnect)Added a
_manualDisconnectflag that is set in_bleDisconnectDeviceand checked inonDeviceDisconnected. When true, skipsperiodicConnectand cancels the reconnection timer.Test plan
🤖 Generated with Claude Code