refactor(service): unify dual connectionState flows into single source of truth (#5077)

This commit is contained in:
James Rich 2026-04-11 19:50:52 -05:00 committed by GitHub
parent 5e44cbd3a9
commit 9468bc6ebe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 103 additions and 8 deletions

View file

@ -30,6 +30,7 @@ class FakeRadioController :
BaseFake(),
RadioController {
/** Canonical app-level connection state, mirroring [ServiceRepository][connectionState] semantics. */
private val _connectionState = mutableStateFlow<ConnectionState>(ConnectionState.Connected)
override val connectionState: StateFlow<ConnectionState> = _connectionState

View file

@ -28,12 +28,20 @@ import org.meshtastic.core.model.InterfaceId
import org.meshtastic.core.model.MeshActivity
import org.meshtastic.core.repository.RadioInterfaceService
/** A test double for [RadioInterfaceService] that provides an in-memory implementation. */
/**
* A test double for [RadioInterfaceService] that provides an in-memory implementation.
*
* The [connectionState] here mirrors the transport-level semantics of the real implementation. In production, only
* [MeshConnectionManager][org.meshtastic.core.repository.MeshConnectionManager] observes this flow; tests should verify
* that bridging behavior rather than consuming it directly from UI/feature test code (use
* [FakeServiceRepository.connectionState] instead).
*/
@Suppress("TooManyFunctions")
class FakeRadioInterfaceService(override val serviceScope: CoroutineScope = MainScope()) : RadioInterfaceService {
override val supportedDeviceTypes: List<DeviceType> = emptyList()
/** Transport-level connection state (raw hardware link status). */
private val _connectionState = MutableStateFlow<ConnectionState>(ConnectionState.Disconnected)
override val connectionState: StateFlow<ConnectionState> = _connectionState

View file

@ -31,6 +31,7 @@ import org.meshtastic.proto.MeshPacket
@Suppress("TooManyFunctions")
class FakeServiceRepository : ServiceRepository {
/** Canonical app-level connection state — the single source of truth for UI/feature tests. */
private val _connectionState = MutableStateFlow<ConnectionState>(ConnectionState.Disconnected)
override val connectionState: StateFlow<ConnectionState> = _connectionState