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