forked from PeterCxy/OpenEUICC
Compare commits
2 commits
f5074acae2
...
03bfdf373c
Author | SHA1 | Date | |
---|---|---|---|
03bfdf373c | |||
9517f53712 |
5 changed files with 32 additions and 4 deletions
|
@ -15,12 +15,21 @@ class EuiccChannelImpl(
|
|||
verboseLoggingFlow: Flow<Boolean>,
|
||||
ignoreTLSCertificateFlow: Flow<Boolean>
|
||||
) : EuiccChannel {
|
||||
companion object {
|
||||
// TODO: This needs to go somewhere else.
|
||||
val ISDR_AID = "A0000005591010FFFFFFFF8900000100".decodeHex()
|
||||
}
|
||||
|
||||
override val slotId = port.card.physicalSlotIndex
|
||||
override val logicalSlotId = port.logicalSlotIndex
|
||||
override val portId = port.portIndex
|
||||
|
||||
override val lpa: LocalProfileAssistant =
|
||||
LocalProfileAssistantImpl(apduInterface, HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow))
|
||||
LocalProfileAssistantImpl(
|
||||
ISDR_AID,
|
||||
apduInterface,
|
||||
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow)
|
||||
)
|
||||
|
||||
override val atr: ByteArray?
|
||||
get() = (apduInterface as? ApduInterfaceAtrProvider)?.atr
|
||||
|
|
|
@ -5,7 +5,11 @@ internal object LpacJni {
|
|||
System.loadLibrary("lpac-jni")
|
||||
}
|
||||
|
||||
external fun createContext(apduInterface: ApduInterface, httpInterface: HttpInterface): Long
|
||||
external fun createContext(
|
||||
isdrAid: ByteArray,
|
||||
apduInterface: ApduInterface,
|
||||
httpInterface: HttpInterface
|
||||
): Long
|
||||
external fun destroyContext(handle: Long)
|
||||
|
||||
external fun euiccInit(handle: Long): Int
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.typeblog.lpac_jni.LocalProfileNotification
|
|||
import net.typeblog.lpac_jni.ProfileDownloadCallback
|
||||
|
||||
class LocalProfileAssistantImpl(
|
||||
isdrAid: ByteArray,
|
||||
rawApduInterface: ApduInterface,
|
||||
rawHttpInterface: HttpInterface
|
||||
): LocalProfileAssistant {
|
||||
|
@ -76,7 +77,7 @@ class LocalProfileAssistantImpl(
|
|||
private val httpInterface = HttpInterfaceWrapper(rawHttpInterface)
|
||||
|
||||
private var finalized = false
|
||||
private var contextHandle: Long = LpacJni.createContext(apduInterface, httpInterface)
|
||||
private var contextHandle: Long = LpacJni.createContext(isdrAid, apduInterface, httpInterface)
|
||||
|
||||
init {
|
||||
if (LpacJni.euiccInit(contextHandle) < 0) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a5a0516f084936e7e87cf7420fb99283fa3052ef
|
||||
Subproject commit 90f7104847d4bb392b275746da20a55177a67573
|
|
@ -37,17 +37,30 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_net_typeblog_lpac_1jni_LpacJni_createContext(JNIEnv *env, jobject thiz,
|
||||
jbyteArray isdr_aid,
|
||||
jobject apdu_interface,
|
||||
jobject http_interface) {
|
||||
struct lpac_jni_ctx *jni_ctx = NULL;
|
||||
struct euicc_ctx *ctx = NULL;
|
||||
jbyte *isdr_java = NULL;
|
||||
uint32_t isdr_len = 0;
|
||||
uint8_t *isdr_c = NULL;
|
||||
|
||||
ctx = calloc(1, sizeof(struct euicc_ctx));
|
||||
jni_ctx = calloc(1, sizeof(struct lpac_jni_ctx));
|
||||
|
||||
isdr_java = (*env)->GetByteArrayElements(env, isdr_aid, JNI_FALSE);
|
||||
isdr_len = (*env)->GetArrayLength(env, isdr_aid);
|
||||
isdr_c = calloc(isdr_len, sizeof(uint8_t));
|
||||
memcpy(isdr_c, isdr_java, isdr_len);
|
||||
(*env)->ReleaseByteArrayElements(env, isdr_aid, isdr_java, JNI_ABORT);
|
||||
|
||||
ctx->apdu.interface = &lpac_jni_apdu_interface;
|
||||
ctx->http.interface = &lpac_jni_http_interface;
|
||||
jni_ctx->apdu_interface = (*env)->NewGlobalRef(env, apdu_interface);
|
||||
jni_ctx->http_interface = (*env)->NewGlobalRef(env, http_interface);
|
||||
ctx->aid = (const uint8_t *) isdr_c;
|
||||
ctx->aid_len = isdr_len;
|
||||
ctx->userdata = (void *) jni_ctx;
|
||||
return (jlong) ctx;
|
||||
}
|
||||
|
@ -60,6 +73,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_destroyContext(JNIEnv *env, jobject thiz, jl
|
|||
(*env)->DeleteGlobalRef(env, jni_ctx->apdu_interface);
|
||||
(*env)->DeleteGlobalRef(env, jni_ctx->http_interface);
|
||||
free(jni_ctx);
|
||||
free((void *) ctx->aid);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue