docs/device_manager.md
This change introduces a lean DeviceMonitoringManager to strictly manage BLE device connections while keeping the existing code structure intact.
File: app/src/main/java/com/bitchat/android/mesh/DeviceMonitoringManager.kt
Key logic:
isBlocked(address): check if a MAC is blocked (auto-clears on expiry).block(address, reason): add MAC to blocklist (15m), disconnect via callback, auto-unblock later.onConnectionEstablished(address): start 15s “first ANNOUNCE” timer and a 60s inactivity timer.onAnnounceReceived(address): cancel the 15s ANNOUNCE timer for that device.onAnyPacketReceived(address): refresh 60s inactivity timer.onDeviceDisconnected(address, status): track error disconnects and block on 5 within 5 minutes.Timers:
BluetoothConnectionManager.ktDeviceMonitoringManager instance and provided a disconnectCallback that:
BluetoothConnectionTracker.BluetoothGattServer.cancelConnection.componentDelegate.onPacketReceived to notify per-device activity to the monitor.BluetoothGattClientManager.ktdeviceMonitor.deviceMonitor.onConnectionEstablished(addr).onCharacteristicChanged), call deviceMonitor.onAnyPacketReceived(addr).deviceMonitor.onDeviceDisconnected(addr, status) to track error bursts.BluetoothGattServerManager.ktdeviceMonitor.onConnectionEstablished(addr).deviceMonitor.onAnyPacketReceived(addr).deviceMonitor.onDeviceDisconnected(addr, status).BluetoothMeshService.kt (in the ANNOUNCE handler where we first map device → peer)Blocked devices:
No ANNOUNCE within 15s of connection:
No packets for >60s:
=5 error disconnects within 5 minutes:
Auto-unblock:
DebugSettingsManager (SystemMessage), e.g.:
BluetoothMeshService.clearAllInternalData() which triggers BluetoothConnectionManager.clearDeviceMonitoringAndTracking().BluetoothConnectionTracker state.addressPeerMap to avoid false positives on unverified announces.mesh/DeviceMonitoringManager.ktmesh/BluetoothConnectionManager.ktmesh/BluetoothGattClientManager.ktmesh/BluetoothGattServerManager.ktmesh/BluetoothMeshService.ktThese changes are small, local, and respect existing structure without broad refactors.