Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/Update-Euicc-Info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 20 additions & 5 deletions src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ data object EumManifest : Manifest<EumManifest.Manufacturer>()
{
@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<List<Long>> = emptyList()
)
}

Expand All @@ -112,11 +113,25 @@ data object EumManifest : Manifest<EumManifest.Manufacturer>()

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
}
Expand Down