From d88f9d4636f9facb797a8deee219e9830eb355e6 Mon Sep 17 00:00:00 2001 From: Misaka13514 Date: Fri, 16 May 2025 19:09:08 +0800 Subject: [PATCH] migrate to eum manifest v2 --- scripts/Update-Euicc-Info.ps1 | 2 +- .../moe/sekiu/minilpa/model/Manifest.kt | 25 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/scripts/Update-Euicc-Info.ps1 b/scripts/Update-Euicc-Info.ps1 index 501e6696..c93293d1 100644 --- a/scripts/Update-Euicc-Info.ps1 +++ b/scripts/Update-Euicc-Info.ps1 @@ -9,7 +9,7 @@ $EuiccInfoUpdateTimePath = "$ProjectRootPath/build/euicc_info_update_time" if (!$CheckExists -or (!(Test-Path $EUMPath) -or !(Test-Path $CIPath)) -or !(Test-Path $EuiccInfoUpdateTimePath)) { - Invoke-WebRequest -Uri 'https://euicc-manual.osmocom.org/docs/pki/eum/manifest.json' -OutFile $EUMPath + Invoke-WebRequest -Uri 'https://euicc-manual.osmocom.org/docs/pki/eum/manifest-v2.json' -OutFile $EUMPath Invoke-WebRequest -Uri 'https://euicc-manual.osmocom.org/docs/pki/ci/manifest.json' -OutFile $CIPath $Timestamp = ([DateTimeOffset](Get-Date)).ToUnixTimeMilliseconds() New-Item $EuiccInfoUpdateTimePath -Force | Out-Null diff --git a/src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt b/src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt index be3916df..7b9b6fb3 100644 --- a/src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt +++ b/src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt @@ -95,9 +95,10 @@ data object EumManifest : Manifest() { @Serializable data class Product( - val pattern : String, + val prefix : String, val name : String, - val chip : String? = null + val chip : String? = null, + @SerialName("in-range") val inRange : List> = emptyList() ) } @@ -112,11 +113,25 @@ data object EumManifest : Manifest() fun findProduct(eum : Manufacturer, eid : String) : Manufacturer.Product? { - val path = Path(eid) for (product in eum.products) { - val matcher = FileSystems.getDefault().getPathMatcher("glob:${product.pattern}") - if (matcher.matches(path)) return product + if (eid.startsWith(product.prefix)) + { + if (product.inRange.isEmpty()) return product + + val suffix = eid.removePrefix(product.prefix) + val number = suffix.takeIf { it.all { c -> c.isDigit() } }?.toLongOrNull() + if (number != null) + { + for (range in product.inRange) + { + if (range.size == 2 && number in range[0]..range[1]) + { + return product + } + } + } + } } return null }