lpac-jni: Uprev lpac libeuicc

* use `-z muldefs` temporarily to work around upstream bug.
This commit is contained in:
Peter Cai 2024-02-25 14:57:52 -05:00
parent 19c63113a1
commit 412fd31477
5 changed files with 25 additions and 51 deletions

View file

@ -1,4 +1,4 @@
APP_ABI := all
APP_SHORT_COMMANDS := true
APP_CFLAGS := -Wno-compound-token-split-by-macro
APP_LDFLAGS := -Wl,--build-id=none
APP_LDFLAGS := -Wl,--build-id=none -z muldefs

@ -1 +1 @@
Subproject commit d06a2a0e1f9bd29d86bc4f0881a84f67cd708aa3
Subproject commit 47f44f911099bffdbdb4854500578ba18ab19d06

View file

@ -2,6 +2,7 @@
#include <euicc/es10b.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "lpac-download.h"
jobject download_state_preparing;
@ -61,16 +62,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
jstring imei, jstring confirmation_code,
jobject callback) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
struct es9p_ctx es9p_ctx = {0};
struct es10b_load_bound_profile_package_result es10b_load_bound_profile_package_result;
struct es10b_authenticate_server_param es10b_authenticate_server_param;
struct es10b_prepare_download_param es10b_prepare_download_param;
char *b64_authenticate_server_response = NULL;
char *b64_prepare_download_response = NULL;
char *b64_bound_profile_package = NULL;
char *b64_euicc_challenge = NULL;
char *b64_euicc_info_1 = NULL;
char *transaction_id = NULL;
const char *_confirmation_code = NULL;
const char *_matching_id = NULL;
const char *_smdp = NULL;
@ -85,63 +77,47 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
if (imei != NULL)
_imei = (*env)->GetStringUTFChars(env, imei, NULL);
es9p_ctx.euicc_ctx = ctx;
es9p_ctx.address = _smdp;
ctx->http.server_address = _smdp;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_preparing);
ret = es10b_get_euicc_challenge(ctx, &b64_euicc_challenge);
if (ret < 0)
goto out;
ret = es10b_get_euicc_info(ctx, &b64_euicc_info_1);
ret = es10b_get_euicc_challenge_and_info(ctx);
syslog(LOG_INFO, "es10b_get_euicc_challenge_and_info %d", ret);
if (ret < 0)
goto out;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_connecting);
ret = es9p_initiate_authentication(&es9p_ctx, &es10b_authenticate_server_param,
b64_euicc_challenge, b64_euicc_info_1);
ret = es9p_initiate_authentication(ctx);
syslog(LOG_INFO, "es9p_initiate_authentication %d", ret);
if (ret < 0)
goto out;
es10b_authenticate_server_param.matchingId = _matching_id;
es10b_authenticate_server_param.imei = _imei;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_authenticating);
ret = es10b_authenticate_server(ctx, &b64_authenticate_server_response,
&es10b_authenticate_server_param);
ret = es10b_authenticate_server(ctx, _matching_id, _imei);
syslog(LOG_INFO, "es10b_authenticate_server %d", ret);
if (ret < 0)
goto out;
ret = es9p_authenticate_client(&es9p_ctx, &es10b_prepare_download_param,
b64_authenticate_server_response);
ret = es9p_authenticate_client(ctx);
if (ret < 0)
goto out;
es10b_prepare_download_param.confirmationCode = _confirmation_code;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_downloading);
ret = es10b_prepare_download(ctx, &b64_prepare_download_response,
&es10b_prepare_download_param);
ret = es10b_prepare_download(ctx, _confirmation_code);
syslog(LOG_INFO, "es10b_prepare_download %d", ret);
if (ret < 0)
goto out;
ret = es9p_get_bound_profile_package(&es9p_ctx, &b64_bound_profile_package,
b64_prepare_download_response);
ret = es9p_get_bound_profile_package(ctx);
if (ret < 0)
goto out;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_finalizing);
// TODO: Expose error code as Java-side exceptions?
ret = es10b_load_bound_profile_package(ctx, &es10b_load_bound_profile_package_result,
b64_bound_profile_package);
ret = es10b_load_bound_profile_package(ctx, &es10b_load_bound_profile_package_result);
syslog(LOG_INFO, "es10b_load_bound_profile_package %d", ret);
out:
es9p_ctx_free(&es9p_ctx);
free(b64_authenticate_server_response);
free(b64_prepare_download_response);
free(b64_euicc_info_1);
free(b64_euicc_challenge);
free(transaction_id);
euicc_http_cleanup(ctx);
if (_confirmation_code != NULL)
(*env)->ReleaseStringUTFChars(env, confirmation_code, _confirmation_code);
if (_matching_id != NULL)

View file

@ -81,10 +81,10 @@ Java_net_typeblog_lpac_1jni_LpacJni_createContext(JNIEnv *env, jobject thiz,
ctx = malloc(sizeof(struct euicc_ctx));
jni_ctx = malloc(sizeof(struct lpac_jni_ctx));
memset(ctx, 0, sizeof(struct lpac_jni_ctx));
memset(ctx, 0, sizeof(struct euicc_ctx));
memset(jni_ctx, 0, sizeof(struct lpac_jni_ctx));
ctx->interface.apdu = &lpac_jni_apdu_interface;
ctx->interface.http = &lpac_jni_http_interface;
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->userdata = (void *) jni_ctx;

View file

@ -84,7 +84,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_es10bListNotification(JNIEnv *env, jobject t
(*env)->DeleteLocalRef(env, notification);
});
es10b_notification_metadata_free_all(info);
es10b_notification_metadata_list_free_all(info);
return ret;
}
@ -92,25 +92,23 @@ 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;
struct es9p_ctx es9p_ctx = {0};
struct es10b_pending_notification notification;
int res;
res = es10b_retrieve_notifications_list(ctx, &notification, (unsigned long) seq_number);
syslog(LOG_DEBUG, "es10b_retrieve_notification = %d", res);
syslog(LOG_DEBUG, "es10b_retrieve_notification = %d %s", res, notification.b64_PendingNotification);
if (res < 0)
goto out;
es9p_ctx.euicc_ctx = ctx;
es9p_ctx.address = notification.notificationAddress;
ctx->http.server_address = notification.notificationAddress;
res = es9p_handle_notification(&es9p_ctx, notification.b64_PendingNotification);
res = es9p_handle_notification(ctx, notification.b64_PendingNotification);
syslog(LOG_DEBUG, "es9p_handle_notification = %d", res);
if (res < 0)
goto out;
out:
es9p_ctx_free(&es9p_ctx);
euicc_http_cleanup(ctx);
return res;
}