Compare commits
2 commits
9f3977dc5e
...
1c0ddefad9
Author | SHA1 | Date | |
---|---|---|---|
1c0ddefad9 | |||
1c7dc67803 |
6 changed files with 55 additions and 41 deletions
|
@ -3,9 +3,7 @@ package net.typeblog.lpac_jni
|
|||
/* Corresponds to EuiccInfo2 in SGP.22 */
|
||||
data class EuiccInfo2(
|
||||
val profileVersion: String,
|
||||
val sgp22Version: String,
|
||||
val euiccFirmwareVersion: String,
|
||||
val uiccFirmwareVersion: String,
|
||||
val globalPlatformVersion: String,
|
||||
val sasAccreditationNumber: String,
|
||||
val ppVersion: String,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
APP_ABI := all
|
||||
APP_SHORT_COMMANDS := true
|
||||
APP_CFLAGS := -Wno-compound-token-split-by-macro
|
||||
APP_LDFLAGS := -Wl,--build-id=none
|
|
@ -1 +1 @@
|
|||
Subproject commit 76baec728ada6e9a7705bffc2e6bd68482acb839
|
||||
Subproject commit c9180539164521d491e63395b25538b80ad8b883
|
|
@ -53,7 +53,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|||
|
||||
euicc_info2_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/EuiccInfo2");
|
||||
euicc_info2_class = (*env)->NewGlobalRef(env, euicc_info2_class);
|
||||
euicc_info2_constructor = (*env)->GetMethodID(env, euicc_info2_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V");
|
||||
euicc_info2_constructor = (*env)->GetMethodID(env, euicc_info2_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V");
|
||||
|
||||
const char _unused[1];
|
||||
empty_string = (*env)->NewString(env, _unused, 0);
|
||||
|
@ -179,24 +179,27 @@ JNIEXPORT jobjectArray JNICALL
|
|||
Java_net_typeblog_lpac_1jni_LpacJni_es10cGetProfilesInfo(JNIEnv *env, jobject thiz, jlong handle) {
|
||||
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
|
||||
struct es10c_profile_info *info = NULL;
|
||||
struct es10c_profile_info *curr = NULL;
|
||||
jobjectArray ret = NULL;
|
||||
jobject jinfo = NULL;
|
||||
int count;
|
||||
int count = 0;
|
||||
|
||||
if (es10c_get_profiles_info(ctx, &info, &count) < 0) {
|
||||
if (es10c_get_profiles_info(ctx, &info) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
count = LPAC_JNI_LINKED_LIST_COUNT(info, curr);
|
||||
|
||||
ret = (*env)->NewObjectArray(env, count, local_profile_info_class, NULL);
|
||||
|
||||
// Convert the native info array to Java
|
||||
for (int i = 0; i < count; i++) {
|
||||
jinfo = profile_info_native_to_java(env, &info[i]);
|
||||
LPAC_JNI_LINKED_LIST_FOREACH(info, curr, {
|
||||
jinfo = profile_info_native_to_java(env, curr);
|
||||
(*env)->SetObjectArrayElement(env, ret, i, jinfo);
|
||||
(*env)->DeleteLocalRef(env, jinfo);
|
||||
}
|
||||
});
|
||||
|
||||
es10c_profile_info_free_all(info, count);
|
||||
es10c_profile_info_free_all(info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -258,40 +261,37 @@ Java_net_typeblog_lpac_1jni_LpacJni_es10cDeleteProfile(JNIEnv *env, jobject thiz
|
|||
JNIEXPORT jobject JNICALL
|
||||
Java_net_typeblog_lpac_1jni_LpacJni_es10cexGetEuiccInfo2(JNIEnv *env, jobject thiz, jlong handle) {
|
||||
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
|
||||
struct es10cex_euiccinfo2 info;
|
||||
struct es10cex_euiccinfo2 * info;
|
||||
jstring sas_accreditation_number = NULL;
|
||||
jstring global_platform_version = NULL;
|
||||
jstring euicc_firmware_version = NULL;
|
||||
jstring uicc_firmware_version = NULL;
|
||||
jstring profile_version = NULL;
|
||||
jstring sgp22_version = NULL;
|
||||
jstring pp_version = NULL;
|
||||
jobject ret = NULL;
|
||||
|
||||
if (es10cex_get_euiccinfo2(ctx, &info) < 0)
|
||||
goto out;
|
||||
|
||||
profile_version = toJString(env, info.profile_version);
|
||||
sgp22_version = toJString(env, info.sgp22_version);
|
||||
euicc_firmware_version = toJString(env, info.euicc_firmware_version);
|
||||
uicc_firmware_version = toJString(env, info.uicc_firmware_version);
|
||||
global_platform_version = toJString(env, info.global_platform_version);
|
||||
sas_accreditation_number = toJString(env, info.sas_accreditation_number);
|
||||
pp_version = toJString(env, info.pp_version);
|
||||
profile_version = toJString(env, info->profileVersion);
|
||||
euicc_firmware_version = toJString(env, info->euiccFirmwareVer);
|
||||
global_platform_version = toJString(env, info->globalplatformVersion);
|
||||
sas_accreditation_number = toJString(env, info->sasAcreditationNumber);
|
||||
pp_version = toJString(env, info->ppVersion);
|
||||
|
||||
ret = (*env)->NewObject(env, euicc_info2_class, euicc_info2_constructor,
|
||||
profile_version, sgp22_version, euicc_firmware_version,
|
||||
uicc_firmware_version, global_platform_version,
|
||||
profile_version, euicc_firmware_version,
|
||||
global_platform_version,
|
||||
sas_accreditation_number, pp_version,
|
||||
info.free_nvram, info.free_ram);
|
||||
info->extCardResource.freeNonVolatileMemory,
|
||||
info->extCardResource.freeVolatileMemory);
|
||||
|
||||
out:
|
||||
(*env)->DeleteLocalRef(env, profile_version);
|
||||
(*env)->DeleteLocalRef(env, sgp22_version);
|
||||
(*env)->DeleteLocalRef(env, euicc_firmware_version);
|
||||
(*env)->DeleteLocalRef(env, uicc_firmware_version);
|
||||
(*env)->DeleteLocalRef(env, global_platform_version);
|
||||
(*env)->DeleteLocalRef(env, sas_accreditation_number);
|
||||
(*env)->DeleteLocalRef(env, pp_version);
|
||||
if (info != NULL)
|
||||
es10cex_free_euiccinfo2(info);
|
||||
return ret;
|
||||
}
|
|
@ -13,6 +13,21 @@ struct lpac_jni_ctx {
|
|||
JNIEnv *env; \
|
||||
(*jvm)->AttachCurrentThread(jvm, &env, NULL)
|
||||
|
||||
#define __LPAC_JNI_LINKED_LIST_FOREACH(list, curr, body, after) { \
|
||||
int i = 0; \
|
||||
curr = list; \
|
||||
while (curr != NULL) { \
|
||||
body; \
|
||||
curr = curr->next; \
|
||||
i++; \
|
||||
}; \
|
||||
after; \
|
||||
}
|
||||
#define LPAC_JNI_LINKED_LIST_FOREACH(list, curr, body) \
|
||||
__LPAC_JNI_LINKED_LIST_FOREACH(list, curr, body, {})
|
||||
#define LPAC_JNI_LINKED_LIST_COUNT(list, curr) \
|
||||
(__LPAC_JNI_LINKED_LIST_FOREACH(list, curr, {}, i))
|
||||
|
||||
extern JavaVM *jvm;
|
||||
extern jclass string_class;
|
||||
|
||||
|
|
|
@ -33,36 +33,39 @@ void lpac_notifications_init() {
|
|||
JNIEXPORT jobject JNICALL
|
||||
Java_net_typeblog_lpac_1jni_LpacJni_es10bListNotification(JNIEnv *env, jobject thiz, jlong handle) {
|
||||
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
|
||||
struct es10b_notification_metadata *info;
|
||||
struct es10b_notification_metadata *info = NULL;
|
||||
struct es10b_notification_metadata *curr = NULL;
|
||||
jobject notification = NULL;
|
||||
jobject operation = NULL;
|
||||
jobjectArray ret = NULL;
|
||||
int count;
|
||||
int count = 0;
|
||||
|
||||
if (es10b_list_notification(ctx, &info, &count) < 0)
|
||||
if (es10b_list_notification(ctx, &info) < 0)
|
||||
return NULL;
|
||||
|
||||
count = LPAC_JNI_LINKED_LIST_COUNT(info, curr);
|
||||
|
||||
ret = (*env)->NewObjectArray(env, count, local_profile_notification_class, NULL);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
LPAC_JNI_LINKED_LIST_FOREACH(info, curr, {
|
||||
operation =
|
||||
(*env)->CallStaticObjectMethod(env, local_profile_notification_operation_class,
|
||||
local_profile_notification_operation_from_string,
|
||||
toJString(env, info[i].profileManagementOperation));
|
||||
toJString(env, curr->profileManagementOperation));
|
||||
|
||||
notification =
|
||||
(*env)->NewObject(env, local_profile_notification_class,
|
||||
local_profile_notification_constructor, info[i].seqNumber, operation,
|
||||
toJString(env, info[i].notificationAddress),
|
||||
toJString(env, info[i].iccid));
|
||||
local_profile_notification_constructor, curr->seqNumber, operation,
|
||||
toJString(env, curr->notificationAddress),
|
||||
toJString(env, curr->iccid));
|
||||
|
||||
(*env)->SetObjectArrayElement(env, ret, i, notification);
|
||||
|
||||
(*env)->DeleteLocalRef(env, operation);
|
||||
(*env)->DeleteLocalRef(env, notification);
|
||||
}
|
||||
});
|
||||
|
||||
es10b_notification_metadata_free_all(info, count);
|
||||
es10b_notification_metadata_free_all(info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -70,23 +73,20 @@ JNIEXPORT jint JNICALL
|
|||
Java_net_typeblog_lpac_1jni_LpacJni_handleNotification(JNIEnv *env, jobject thiz, jlong handle,
|
||||
jlong seq_number) {
|
||||
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
|
||||
char *b64_payload = NULL;
|
||||
char *receiver = NULL;
|
||||
struct es10b_notification notification;
|
||||
int res;
|
||||
|
||||
res = es10b_retrieve_notification(ctx, &b64_payload, &receiver, (unsigned long) seq_number);
|
||||
res = es10b_retrieve_notification(ctx, ¬ification, (unsigned long) seq_number);
|
||||
syslog(LOG_DEBUG, "es10b_retrieve_notification = %d", res);
|
||||
if (res < 0)
|
||||
goto out;
|
||||
|
||||
res = es9p_handle_notification(ctx, receiver, b64_payload);
|
||||
res = es9p_handle_notification(ctx, notification.receiver, notification.b64_payload);
|
||||
syslog(LOG_DEBUG, "es9p_handle_notification = %d", res);
|
||||
if (res < 0)
|
||||
goto out;
|
||||
|
||||
out:
|
||||
free(b64_payload);
|
||||
free(receiver);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue