Compare commits

...

2 commits

Author SHA1 Message Date
5ab07d6262 README: Mention more clearly it's GNU GPL v3
All checks were successful
/ build-debug (push) Successful in 4m44s
2024-09-03 21:45:50 -04:00
394cad2eac refactor: lpac-jni: Use C macros to generate struct-exposing functions 2024-09-03 21:35:41 -04:00
5 changed files with 39 additions and 36 deletions

View file

@ -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) - 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` - 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) Building (Gradle)
=== ===

View file

@ -35,7 +35,7 @@ internal object LpacJni {
// C <-> Java struct / linked list handling // C <-> Java struct / linked list handling
// Notifications // Notifications
external fun notificationNext(curr: Long): Long external fun notificationsNext(curr: Long): Long
external fun notificationGetSeq(curr: Long): Long external fun notificationGetSeq(curr: Long): Long
external fun notificationGetOperationString(curr: Long): String external fun notificationGetOperationString(curr: Long): String
external fun notificationGetAddress(curr: Long): String external fun notificationGetAddress(curr: Long): String

View file

@ -56,7 +56,7 @@ class LocalProfileAssistantImpl(
LpacJni.notificationGetAddress(curr), LpacJni.notificationGetAddress(curr),
LpacJni.notificationGetIccid(curr), LpacJni.notificationGetIccid(curr),
)) ))
curr = LpacJni.notificationNext(curr) curr = LpacJni.notificationsNext(curr)
} }
LpacJni.notificationsFree(head) LpacJni.notificationsFree(head)
return ret.sortedBy { it.seqNumber }.reversed() return ret.sortedBy { it.seqNumber }.reversed()

View file

@ -50,4 +50,31 @@ struct lpac_jni_ctx {
extern JavaVM *jvm; extern JavaVM *jvm;
extern jclass string_class; extern jclass string_class;
jstring toJString(JNIEnv *env, const char *pat); 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); \
}

View file

@ -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); 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 JNIEXPORT jstring JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_notificationGetOperationString(JNIEnv *env, jobject thiz, Java_net_typeblog_lpac_1jni_LpacJni_notificationGetOperationString(JNIEnv *env, jobject thiz,
jlong curr) { jlong curr) {
@ -87,21 +72,8 @@ Java_net_typeblog_lpac_1jni_LpacJni_notificationGetOperationString(JNIEnv *env,
return toJString(env, profileManagementOperationStr); return toJString(env, profileManagementOperationStr);
} }
JNIEXPORT jstring JNICALL LPAC_JNI_STRUCT_GETTER_LINKED_LIST_NEXT(struct es10b_notification_metadata_list, notifications)
Java_net_typeblog_lpac_1jni_LpacJni_notificationGetAddress(JNIEnv *env, jobject thiz, jlong curr) { LPAC_JNI_STRUCT_LINKED_LIST_FREE(struct es10b_notification_metadata_list, notifications, es10b_notification_metadata_list_free_all)
struct es10b_notification_metadata_list *info = (struct es10b_notification_metadata_list *) curr; LPAC_JNI_STRUCT_GETTER_LONG(struct es10b_notification_metadata_list, seqNumber, Seq)
return toJString(env, info->notificationAddress); LPAC_JNI_STRUCT_GETTER_STRING(struct es10b_notification_metadata_list, notificationAddress, Address)
} LPAC_JNI_STRUCT_GETTER_STRING(struct es10b_notification_metadata_list, iccid, Iccid)
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);
}