diff --git a/scripts/Update-Euicc-Info.ps1 b/scripts/Update-Euicc-Info.ps1 index 501e669..c93293d 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 be3916d..7b9b6fb 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 }