fix: break Koin circular dependency with Lazy<MeshConnectionManager>

MeshConnectionManagerImpl and LockdownCoordinatorImpl constructor-inject
each other, causing a StackOverflowError at Koin resolution time.

The coordinator only needs MeshConnectionManager in two rare paths
(lock-now-ack and post-unlock config reload), so defer its resolution
with Lazy<T> — matching the existing Lazy<MeshRouter> pattern in
FromRadioPacketHandlerImpl.
This commit is contained in:
James Rich
2026-05-13 12:19:22 -05:00
parent 2a1734d932
commit 2b1ccd653a
3 changed files with 5 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ class LockdownCoordinatorImpl(
private val commandSender: CommandSender,
private val passphraseStore: LockdownPassphraseStore,
private val radioInterfaceService: RadioInterfaceService,
private val connectionManager: MeshConnectionManager,
private val connectionManager: Lazy<MeshConnectionManager>,
) : LockdownCoordinator {
@Volatile private var wasAutoAttempt = false
@@ -86,7 +86,7 @@ class LockdownCoordinatorImpl(
Logger.i { "Lockdown: Lock Now acknowledged — resetting session authorization" }
serviceRepository.setSessionAuthorized(false)
resetTransientState()
connectionManager.clearRadioConfig()
connectionManager.value.clearRadioConfig()
serviceRepository.setLockdownState(LockdownState.LockNowAcknowledged)
}
@@ -141,7 +141,7 @@ class LockdownCoordinatorImpl(
)
serviceRepository.setLockdownState(LockdownState.Unlocked)
serviceRepository.setSessionAuthorized(true)
connectionManager.startConfigOnly()
connectionManager.value.startConfigOnly()
}
@Suppress("TooGenericExceptionCaught")

View File

@@ -34,6 +34,7 @@ import org.meshtastic.proto.ClientNotification
import org.meshtastic.proto.Config
import org.meshtastic.proto.DeviceMetadata
import org.meshtastic.proto.FromRadio
import org.meshtastic.proto.LockdownStatus
import org.meshtastic.proto.ModuleConfig
import org.meshtastic.proto.MqttClientProxyMessage
import org.meshtastic.proto.MyNodeInfo
@@ -42,7 +43,6 @@ import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import org.meshtastic.proto.LockdownStatus
import org.meshtastic.proto.NodeInfo as ProtoNodeInfo
class FromRadioPacketHandlerImplTest {

View File

@@ -151,7 +151,7 @@ class LockdownCoordinatorImplTest {
commandSender = commandSender,
passphraseStore = passphraseStore,
radioInterfaceService = radioService,
connectionManager = connectionManager,
connectionManager = lazy { connectionManager },
)
private val testDeviceAddress = "AA:BB:CC:DD:EE:FF"