diff --git a/README.md b/README.md index 24f4c9f..f8019b2 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ There are two variants of this project: - Prebuilt release-mode EasyEUICC apks can be downloaded [here](https://gitea.angry.im/PeterCxy/OpenEUICC/releases) - For removable eSIM chip vendors: to have your chip supported by official builds of EasyEUICC when inserted, include the ARA-M hash `2A2FA878BC7C3354C2CF82935A5945A3EDAE4AFA` +__This project is Free Software licensed under GNU GPL v3, WITHOUT the "or later" clause.__ Any modification and derivative work __MUST__ be released under the SAME license, which means, at the very least, that the source code __MUST__ be available upon request. + +__If you are releasing a modification of this app, you are kindly asked to make changes to at least the app name and package name.__ + Building (Gradle) === diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LpacJni.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LpacJni.kt index 884c81a..37406a7 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LpacJni.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LpacJni.kt @@ -35,7 +35,7 @@ internal object LpacJni { // C <-> Java struct / linked list handling // Notifications - external fun notificationNext(curr: Long): Long + external fun notificationsNext(curr: Long): Long external fun notificationGetSeq(curr: Long): Long external fun notificationGetOperationString(curr: Long): String external fun notificationGetAddress(curr: Long): String diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt index 0b6aa1d..0b03b64 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt @@ -56,7 +56,7 @@ class LocalProfileAssistantImpl( LpacJni.notificationGetAddress(curr), LpacJni.notificationGetIccid(curr), )) - curr = LpacJni.notificationNext(curr) + curr = LpacJni.notificationsNext(curr) } LpacJni.notificationsFree(head) return ret.sortedBy { it.seqNumber }.reversed() diff --git a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-jni.h b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-jni.h index 1915c5e..4d537ee 100644 --- a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-jni.h +++ b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-jni.h @@ -50,4 +50,31 @@ struct lpac_jni_ctx { extern JavaVM *jvm; extern jclass string_class; -jstring toJString(JNIEnv *env, const char *pat); \ No newline at end of file +jstring toJString(JNIEnv *env, const char *pat); + +#define LPAC_JNI_STRUCT_GETTER_LINKED_LIST_NEXT(st, st_jname) \ + JNIEXPORT jlong JNICALL Java_net_typeblog_lpac_1jni_LpacJni_##st_jname##Next(JNIEnv *env, jobject thiz, jlong raw) { \ + st *p = (st *) raw; \ + if (p == NULL) return 0; \ + return (jlong) p->next; \ + } + +#define LPAC_JNI_STRUCT_LINKED_LIST_FREE(st, st_jname, free_func) \ + JNIEXPORT void JNICALL Java_net_typeblog_lpac_1jni_LpacJni_##st_jname##Free(JNIEnv *env, jobject thiz, jlong raw) { \ + st *p = (st *) raw; \ + if (p == NULL) return; \ + free_func(p); \ + } + +#define LPAC_JNI_STRUCT_GETTER_LONG(st, name, jname) \ + JNIEXPORT jlong JNICALL Java_net_typeblog_lpac_1jni_LpacJni_notificationGet##jname(JNIEnv *env, jobject thiz, jlong raw) { \ + st *p = (st *) raw; \ + if (p == NULL) return 0; \ + return (jlong) p->name; \ + } + +#define LPAC_JNI_STRUCT_GETTER_STRING(st, name, jname) \ + JNIEXPORT jstring JNICALL Java_net_typeblog_lpac_1jni_LpacJni_notificationGet##jname(JNIEnv *env, jobject thiz, jlong raw) { \ + st *p = (st *) raw; \ + return toJString(env, p->name); \ + } \ No newline at end of file diff --git a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-notifications.c b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-notifications.c index cfb1e59..bd4dffd 100644 --- a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-notifications.c +++ b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-notifications.c @@ -46,21 +46,6 @@ Java_net_typeblog_lpac_1jni_LpacJni_es10bDeleteNotification(JNIEnv *env, jobject return es10b_remove_notification_from_list(ctx, (unsigned long) seq_number); } -JNIEXPORT jlong JNICALL -Java_net_typeblog_lpac_1jni_LpacJni_notificationNext(JNIEnv *env, jobject thiz, jlong curr) { - struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) curr; - if (info == NULL) { - return 0; - } - return (jlong) info->next; -} - -JNIEXPORT jlong JNICALL -Java_net_typeblog_lpac_1jni_LpacJni_notificationGetSeq(JNIEnv *env, jobject thiz, jlong curr) { - struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) curr; - return info->seqNumber; -} - JNIEXPORT jstring JNICALL Java_net_typeblog_lpac_1jni_LpacJni_notificationGetOperationString(JNIEnv *env, jobject thiz, jlong curr) { @@ -87,21 +72,8 @@ Java_net_typeblog_lpac_1jni_LpacJni_notificationGetOperationString(JNIEnv *env, return toJString(env, profileManagementOperationStr); } -JNIEXPORT jstring JNICALL -Java_net_typeblog_lpac_1jni_LpacJni_notificationGetAddress(JNIEnv *env, jobject thiz, jlong curr) { - struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) curr; - return toJString(env, info->notificationAddress); -} - -JNIEXPORT jstring JNICALL -Java_net_typeblog_lpac_1jni_LpacJni_notificationGetIccid(JNIEnv *env, jobject thiz, jlong curr) { - struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) curr; - return toJString(env, info->iccid); -} - -JNIEXPORT void JNICALL -Java_net_typeblog_lpac_1jni_LpacJni_notificationsFree(JNIEnv *env, jobject thiz, jlong head) { - struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) head; - if (info == NULL) return; - es10b_notification_metadata_list_free_all(info); -} \ No newline at end of file +LPAC_JNI_STRUCT_GETTER_LINKED_LIST_NEXT(struct es10b_notification_metadata_list, notifications) +LPAC_JNI_STRUCT_LINKED_LIST_FREE(struct es10b_notification_metadata_list, notifications, es10b_notification_metadata_list_free_all) +LPAC_JNI_STRUCT_GETTER_LONG(struct es10b_notification_metadata_list, seqNumber, Seq) +LPAC_JNI_STRUCT_GETTER_STRING(struct es10b_notification_metadata_list, notificationAddress, Address) +LPAC_JNI_STRUCT_GETTER_STRING(struct es10b_notification_metadata_list, iccid, Iccid) \ No newline at end of file