mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(service): initialize PacketHandler lazily (#2833)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
6895af1653
commit
9fd184d3ac
1 changed files with 8 additions and 10 deletions
|
|
@ -211,8 +211,14 @@ class MeshService :
|
|||
MeshServiceBroadcasts(this, clientPackages) {
|
||||
connectionState.also { radioConfigRepository.setConnectionState(it) }
|
||||
}
|
||||
private lateinit var packetHandler: PacketHandler
|
||||
|
||||
private val packetHandler: PacketHandler by lazy {
|
||||
PacketHandler(
|
||||
packetRepository = packetRepository,
|
||||
serviceBroadcasts = serviceBroadcasts,
|
||||
radioInterfaceService = radioInterfaceService,
|
||||
meshLogRepository = meshLogRepository,
|
||||
)
|
||||
}
|
||||
private val serviceJob = Job()
|
||||
private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
|
||||
private var connectionState = ConnectionState.DISCONNECTED
|
||||
|
|
@ -330,14 +336,6 @@ class MeshService :
|
|||
|
||||
loadSettings() // Load our last known node DB
|
||||
|
||||
packetHandler =
|
||||
PacketHandler(
|
||||
packetRepository = packetRepository,
|
||||
serviceBroadcasts = serviceBroadcasts,
|
||||
radioInterfaceService = radioInterfaceService,
|
||||
meshLogRepository = meshLogRepository,
|
||||
)
|
||||
|
||||
// the rest of our init will happen once we are in radioConnection.onServiceConnected
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue