mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(service): unify dual connectionState flows into single source of truth (#5077)
This commit is contained in:
parent
5e44cbd3a9
commit
9468bc6ebe
12 changed files with 103 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue