mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-06-02 06:24:16 +02:00
refactor: leverage new dependency features from recent updates (#5057)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user