refactor: coroutine dispatchers and modernize testing infrastructure (#4901)
Some checks are pending
Dependency Submission / dependency-submission (push) Waiting to run
Main CI (Verify & Build) / validate-and-build (push) Waiting to run
Main Push Changelog / Generate main push changelog (push) Waiting to run

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-23 20:31:48 -05:00 committed by GitHub
parent 664ebf218e
commit 96060a0a4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 621 additions and 182 deletions

View file

@ -66,6 +66,9 @@ import org.meshtastic.core.service.di.module as coreServiceModule
import org.meshtastic.core.ui.di.module as coreUiModule
import org.meshtastic.desktop.di.module as desktopDiModule
import org.meshtastic.feature.connections.di.module as featureConnectionsModule
import org.meshtastic.feature.firmware.di.module as featureFirmwareModule
import org.meshtastic.feature.intro.di.module as featureIntroModule
import org.meshtastic.feature.map.di.module as featureMapModule
import org.meshtastic.feature.messaging.di.module as featureMessagingModule
import org.meshtastic.feature.node.di.module as featureNodeModule
import org.meshtastic.feature.settings.di.module as featureSettingsModule
@ -100,6 +103,9 @@ fun desktopModule() = module {
org.meshtastic.feature.node.di.FeatureNodeModule().featureNodeModule(),
org.meshtastic.feature.messaging.di.FeatureMessagingModule().featureMessagingModule(),
org.meshtastic.feature.connections.di.FeatureConnectionsModule().featureConnectionsModule(),
org.meshtastic.feature.map.di.FeatureMapModule().featureMapModule(),
org.meshtastic.feature.firmware.di.FeatureFirmwareModule().featureFirmwareModule(),
org.meshtastic.feature.intro.di.FeatureIntroModule().featureIntroModule(),
org.meshtastic.desktop.di.DesktopDiModule().desktopDiModule(),
desktopPlatformStubsModule(),
)
@ -168,4 +174,13 @@ private fun desktopPlatformStubsModule() = module {
override fun loadBootloaderOtaQuirksFromJsonAsset(): List<BootloaderOtaQuirk> = emptyList()
}
}
// Firmware update stubs
single<org.meshtastic.feature.firmware.FirmwareUpdateManager> {
org.meshtastic.desktop.stub.NoopFirmwareUpdateManager()
}
single<org.meshtastic.feature.firmware.FirmwareUsbManager> { org.meshtastic.desktop.stub.NoopFirmwareUsbManager() }
single<org.meshtastic.feature.firmware.FirmwareFileHandler> {
org.meshtastic.desktop.stub.NoopFirmwareFileHandler()
}
}

View file

@ -40,7 +40,10 @@ class DesktopMeshServiceNotifications(private val notificationManager: Notificat
// no-op for desktop
}
override fun updateServiceStateNotification(summaryString: String?, telemetry: Telemetry?): Any {
override fun updateServiceStateNotification(
state: org.meshtastic.core.model.ConnectionState,
telemetry: Telemetry?,
): Any {
// We don't have a foreground service on desktop
return Unit
}

View file

@ -0,0 +1,75 @@
/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.desktop.stub
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import org.meshtastic.core.common.util.CommonUri
import org.meshtastic.core.database.entity.FirmwareRelease
import org.meshtastic.core.model.DeviceHardware
import org.meshtastic.feature.firmware.DfuInternalState
import org.meshtastic.feature.firmware.FirmwareFileHandler
import org.meshtastic.feature.firmware.FirmwareUpdateManager
import org.meshtastic.feature.firmware.FirmwareUpdateState
import org.meshtastic.feature.firmware.FirmwareUsbManager
class NoopFirmwareUpdateManager : FirmwareUpdateManager {
override suspend fun startUpdate(
release: FirmwareRelease,
hardware: DeviceHardware,
address: String,
updateState: (FirmwareUpdateState) -> Unit,
firmwareUri: CommonUri?,
): String? = null
override fun dfuProgressFlow(): Flow<DfuInternalState> = emptyFlow()
}
class NoopFirmwareUsbManager : FirmwareUsbManager {
override fun deviceDetachFlow(): Flow<Unit> = emptyFlow()
}
@Suppress("EmptyFunctionBlock")
class NoopFirmwareFileHandler : FirmwareFileHandler {
override fun cleanupAllTemporaryFiles() {}
override suspend fun checkUrlExists(url: String): Boolean = false
override suspend fun downloadFile(url: String, fileName: String, onProgress: (Float) -> Unit): String? = null
override suspend fun extractFirmware(
uri: CommonUri,
hardware: DeviceHardware,
fileExtension: String,
preferredFilename: String?,
): String? = null
override suspend fun extractFirmwareFromZip(
zipFilePath: String,
hardware: DeviceHardware,
fileExtension: String,
preferredFilename: String?,
): String? = null
override suspend fun getFileSize(path: String): Long = 0L
override suspend fun deleteFile(path: String) {}
override suspend fun copyFileToUri(sourcePath: String, destinationUri: CommonUri): Long = 0L
override suspend fun copyUriToUri(sourceUri: CommonUri, destinationUri: CommonUri): Long = 0L
}

View file

@ -111,7 +111,10 @@ class NoopMeshServiceNotifications : MeshServiceNotifications {
override fun initChannels() {}
override fun updateServiceStateNotification(summaryString: String?, telemetry: Telemetry?): Any = Unit
override fun updateServiceStateNotification(
state: org.meshtastic.core.model.ConnectionState,
telemetry: Telemetry?,
): Any = Unit
override suspend fun updateMessageNotification(
contactKey: String,