Compare commits

..

1 commit

Author SHA1 Message Date
6bb05d910b [1/n] Add seId parameter to withEuiccChannel()
Defaults to 0 so that it doesn't break everything else.
2025-05-18 11:46:56 -04:00
5 changed files with 23 additions and 22 deletions

View file

@ -1,7 +1,7 @@
on: on:
push: push:
branches: branches:
- '*' - 'master'
jobs: jobs:
build-debug: build-debug:

View file

@ -174,6 +174,7 @@ open class DefaultEuiccChannelManager(
override suspend fun <R> withEuiccChannel( override suspend fun <R> withEuiccChannel(
physicalSlotId: Int, physicalSlotId: Int,
portId: Int, portId: Int,
seId: Int,
fn: suspend (EuiccChannel) -> R fn: suspend (EuiccChannel) -> R
): R { ): R {
val channel = findEuiccChannelByPort(physicalSlotId, portId) val channel = findEuiccChannelByPort(physicalSlotId, portId)
@ -190,6 +191,7 @@ open class DefaultEuiccChannelManager(
override suspend fun <R> withEuiccChannel( override suspend fun <R> withEuiccChannel(
logicalSlotId: Int, logicalSlotId: Int,
seId: Int,
fn: suspend (EuiccChannel) -> R fn: suspend (EuiccChannel) -> R
): R { ): R {
val channel = findEuiccChannelByLogicalSlot(logicalSlotId) val channel = findEuiccChannelByLogicalSlot(logicalSlotId)

View file

@ -81,6 +81,7 @@ interface EuiccChannelManager {
suspend fun <R> withEuiccChannel( suspend fun <R> withEuiccChannel(
physicalSlotId: Int, physicalSlotId: Int,
portId: Int, portId: Int,
seId: Int = 0,
fn: suspend (EuiccChannel) -> R fn: suspend (EuiccChannel) -> R
): R ): R
@ -89,6 +90,7 @@ interface EuiccChannelManager {
*/ */
suspend fun <R> withEuiccChannel( suspend fun <R> withEuiccChannel(
logicalSlotId: Int, logicalSlotId: Int,
seId: Int = 0,
fn: suspend (EuiccChannel) -> R fn: suspend (EuiccChannel) -> R
): R ): R

View file

@ -27,13 +27,6 @@ import kotlinx.coroutines.launch
import net.typeblog.lpac_jni.impl.PKID_GSMA_LIVE_CI import net.typeblog.lpac_jni.impl.PKID_GSMA_LIVE_CI
import net.typeblog.lpac_jni.impl.PKID_GSMA_TEST_CI import net.typeblog.lpac_jni.impl.PKID_GSMA_TEST_CI
// https://euicc-manual.osmocom.org/docs/pki/eum/accredited.json
// ref: <https://regex101.com/r/5FFz8u>
private val RE_SAS = Regex(
"""^[A-Z]{2}-[A-Z]{2}(?:-UP)?-\d{4}T?(?:-\d+)?T?$""",
setOf(RegexOption.IGNORE_CASE),
)
class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker { class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
companion object { companion object {
private val YES_NO = Pair(R.string.yes, R.string.no) private val YES_NO = Pair(R.string.yes, R.string.no)
@ -99,7 +92,7 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
lifecycleScope.launch { lifecycleScope.launch {
(infoList.adapter!! as EuiccInfoAdapter).euiccInfoItems = (infoList.adapter!! as EuiccInfoAdapter).euiccInfoItems =
euiccChannelManager.withEuiccChannel(logicalSlotId, ::buildEuiccInfoItems) euiccChannelManager.withEuiccChannel(logicalSlotId, fn = ::buildEuiccInfoItems)
swipeRefresh.isRefreshing = false swipeRefresh.isRefreshing = false
} }
@ -116,14 +109,13 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
vendorInfo.firmwareVersion?.let { add(Item(R.string.euicc_info_fw_ver, it)) } vendorInfo.firmwareVersion?.let { add(Item(R.string.euicc_info_fw_ver, it)) }
vendorInfo.bootloaderVersion?.let { add(Item(R.string.euicc_info_bl_ver, it)) } vendorInfo.bootloaderVersion?.let { add(Item(R.string.euicc_info_bl_ver, it)) }
} }
channel.lpa.euiccInfo2?.let { info -> channel.lpa.euiccInfo2.let { info ->
add(Item(R.string.euicc_info_sgp22_version, info.sgp22Version.toString())) add(Item(R.string.euicc_info_sgp22_version, info?.sgp22Version.toString()))
add(Item(R.string.euicc_info_firmware_version, info.euiccFirmwareVersion.toString())) add(Item(R.string.euicc_info_firmware_version, info?.euiccFirmwareVersion.toString()))
add(Item(R.string.euicc_info_globalplatform_version, info.globalPlatformVersion.toString())) add(Item(R.string.euicc_info_globalplatform_version, info?.globalPlatformVersion.toString()))
add(Item(R.string.euicc_info_pp_version, info.ppVersion.toString())) add(Item(R.string.euicc_info_pp_version, info?.ppVersion.toString()))
info.sasAccreditationNumber.trim().takeIf(RE_SAS::matches) add(Item(R.string.euicc_info_sas_accreditation_number, info?.sasAccreditationNumber))
?.let { add(Item(R.string.euicc_info_sas_accreditation_number, it.uppercase())) } add(Item(R.string.euicc_info_free_nvram, info?.freeNvram?.let(::formatFreeSpace)))
add(Item(R.string.euicc_info_free_nvram, info.freeNvram.let(::formatFreeSpace)))
} }
channel.lpa.euiccInfo2?.euiccCiPKIdListForSigning.orEmpty().let { signers -> channel.lpa.euiccInfo2?.euiccCiPKIdListForSigning.orEmpty().let { signers ->
// SGP.28 v1.0, eSIM CI Registration Criteria (Page 5 of 9, 2019-10-24) // SGP.28 v1.0, eSIM CI Registration Criteria (Page 5 of 9, 2019-10-24)
@ -138,13 +130,18 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
} }
add(Item(R.string.euicc_info_ci_type, getString(resId))) add(Item(R.string.euicc_info_ci_type, getString(resId)))
} }
val atr = channel.atr?.encodeHex() ?: getString(R.string.information_unavailable) val atr = channel.atr?.encodeHex() ?: getString(R.string.information_unavailable)
add(Item(R.string.euicc_info_atr, atr, copiedToastResId = R.string.toast_atr_copied)) add(Item(R.string.euicc_info_atr, atr, copiedToastResId = R.string.toast_atr_copied))
} }
@Suppress("SameParameterValue")
private fun formatByBoolean(b: Boolean, res: Pair<Int, Int>): String = private fun formatByBoolean(b: Boolean, res: Pair<Int, Int>): String =
getString(if (b) res.first else res.second) getString(
if (b) {
res.first
} else {
res.second
}
)
inner class EuiccInfoViewHolder(root: View) : ViewHolder(root) { inner class EuiccInfoViewHolder(root: View) : ViewHolder(root) {
private val title: TextView = root.requireViewById(R.id.euicc_info_title) private val title: TextView = root.requireViewById(R.id.euicc_info_title)

View file

@ -80,7 +80,7 @@ apdu_interface_transmit(struct euicc_ctx *ctx, uint8_t **rx, uint32_t *rx_len, c
LPAC_JNI_EXCEPTION_RETURN; LPAC_JNI_EXCEPTION_RETURN;
*rx_len = (*env)->GetArrayLength(env, ret); *rx_len = (*env)->GetArrayLength(env, ret);
*rx = calloc(*rx_len, sizeof(uint8_t)); *rx = calloc(*rx_len, sizeof(uint8_t));
(*env)->GetByteArrayRegion(env, ret, 0, *rx_len, (jbyte *) *rx); (*env)->GetByteArrayRegion(env, ret, 0, *rx_len, *rx);
(*env)->DeleteLocalRef(env, txArr); (*env)->DeleteLocalRef(env, txArr);
(*env)->DeleteLocalRef(env, ret); (*env)->DeleteLocalRef(env, ret);
return 0; return 0;
@ -113,7 +113,7 @@ http_interface_transmit(struct euicc_ctx *ctx, const char *url, uint32_t *rcode,
jbyteArray rxArr = (jbyteArray) (*env)->GetObjectField(env, ret, field_resp_data); jbyteArray rxArr = (jbyteArray) (*env)->GetObjectField(env, ret, field_resp_data);
*rx_len = (*env)->GetArrayLength(env, rxArr); *rx_len = (*env)->GetArrayLength(env, rxArr);
*rx = calloc(*rx_len, sizeof(uint8_t)); *rx = calloc(*rx_len, sizeof(uint8_t));
(*env)->GetByteArrayRegion(env, rxArr, 0, *rx_len, (jbyte *) *rx); (*env)->GetByteArrayRegion(env, rxArr, 0, *rx_len, *rx);
(*env)->DeleteLocalRef(env, txArr); (*env)->DeleteLocalRef(env, txArr);
(*env)->DeleteLocalRef(env, rxArr); (*env)->DeleteLocalRef(env, rxArr);
(*env)->DeleteLocalRef(env, headersArr); (*env)->DeleteLocalRef(env, headersArr);