refactor: leverage new dependency features from recent updates (#5057)

This commit is contained in:
James Rich
2026-04-10 17:51:08 -05:00
committed by GitHub
parent 929e273978
commit 9c8532f80d
18 changed files with 47 additions and 57 deletions
+2 -1
View File
@@ -58,11 +58,12 @@ kotlin {
androidMain.dependencies { implementation(libs.markdown.renderer.android) }
commonTest.dependencies { implementation(projects.core.testing) }
val androidHostTest by getting {
dependencies {
implementation(libs.junit)
implementation(libs.kotlinx.coroutines.test)
implementation(libs.androidx.compose.ui.test.junit4)
implementation(libs.androidx.test.ext.junit)
}
}
@@ -17,7 +17,9 @@
package org.meshtastic.feature.firmware.ota.dfu
import co.touchlab.kermit.Logger
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonDecodingException
private val json = Json { ignoreUnknownKeys = true }
@@ -36,7 +38,11 @@ internal fun parseDfuZipEntries(entries: Map<String, ByteArray>): DfuZipPackage
val manifest =
runCatching { json.decodeFromString<DfuManifest>(manifestBytes.decodeToString()) }
.getOrElse { e -> throw DfuException.InvalidPackage("Failed to parse manifest.json: ${e.message}") }
.getOrElse { e ->
@OptIn(ExperimentalSerializationApi::class)
val detail = (e as? JsonDecodingException)?.shortMessage ?: e.message
throw DfuException.InvalidPackage("Failed to parse manifest.json: $detail")
}
val entry =
manifest.manifest.primaryEntry ?: throw DfuException.InvalidPackage("No firmware entry found in manifest.json")