Compare commits
1 commit
f507dae186
...
2cce9920f1
Author | SHA1 | Date | |
---|---|---|---|
2cce9920f1 |
1 changed files with 25 additions and 14 deletions
|
@ -60,14 +60,19 @@ void lpac_download_init() {
|
|||
set_cancelled = (*env)->GetMethodID(env, download_callback_class, "setCancelled", "(Z)V");
|
||||
}
|
||||
|
||||
#define IS_CANCELLED (*env)->CallBooleanMethod(env, callback, is_cancelled) == JNI_TRUE
|
||||
#define SET_CANCELLED(VALUE) (*env)->CallVoidMethod(env, callback, set_cancelled, VALUE)
|
||||
#define IS_CANCELLED (*env)->CallBooleanMethod(env, callback, is_cancelled)
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, jlong handle,
|
||||
jstring smdp, jstring matching_id,
|
||||
jstring imei, jstring confirmation_code,
|
||||
jobject callback) {
|
||||
Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(
|
||||
JNIEnv *env,
|
||||
__attribute__((unused)) jobject thiz,
|
||||
jlong handle,
|
||||
jstring smdp,
|
||||
jstring matching_id,
|
||||
jstring imei,
|
||||
jstring confirmation_code,
|
||||
jobject callback
|
||||
) {
|
||||
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
|
||||
struct es10b_load_bound_profile_package_result es10b_load_bound_profile_package_result;
|
||||
const char *_confirmation_code = NULL;
|
||||
|
@ -86,10 +91,11 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
|
||||
ctx->http.server_address = _smdp;
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
// callback.onStateUpdate(DownloadState.Preparing)
|
||||
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_preparing);
|
||||
ret = es10b_get_euicc_challenge_and_info(ctx);
|
||||
syslog(LOG_INFO, "es10b_get_euicc_challenge_and_info %d", ret);
|
||||
|
@ -98,10 +104,12 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
// callback.onStateUpdate(DownloadState.Connecting)
|
||||
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_connecting);
|
||||
ret = es9p_initiate_authentication(ctx);
|
||||
syslog(LOG_INFO, "es9p_initiate_authentication %d", ret);
|
||||
|
@ -110,10 +118,11 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
// callback.onStateUpdate(DownloadState.Authenticating)
|
||||
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_authenticating);
|
||||
ret = es10b_authenticate_server(ctx, _matching_id, _imei);
|
||||
syslog(LOG_INFO, "es10b_authenticate_server %d", ret);
|
||||
|
@ -122,7 +131,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
|
@ -133,10 +142,11 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
// callback.onStateUpdate(DownloadState.Downloading)
|
||||
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_downloading);
|
||||
ret = es10b_prepare_download(ctx, _confirmation_code);
|
||||
syslog(LOG_INFO, "es10b_prepare_download %d", ret);
|
||||
|
@ -145,7 +155,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
|
@ -154,10 +164,11 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
if (IS_CANCELLED) {
|
||||
if (IS_CANCELLED) { // callback.isCancelled()
|
||||
ret = -ES10B_ERROR_REASON_UNDEFINED;
|
||||
goto out;
|
||||
}
|
||||
// callback.onStateUpdate(DownloadState.Finalizing)
|
||||
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_finalizing);
|
||||
ret = es10b_load_bound_profile_package(ctx, &es10b_load_bound_profile_package_result);
|
||||
syslog(LOG_INFO, "es10b_load_bound_profile_package %d, reason %d", ret, es10b_load_bound_profile_package_result.errorReason);
|
||||
|
@ -170,7 +181,7 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
|
|||
|
||||
out:
|
||||
if (IS_CANCELLED == 0 && ret == -ES10B_ERROR_REASON_UNDEFINED) {
|
||||
SET_CANCELLED(JNI_TRUE);
|
||||
(*env)->CallVoidMethod(env, callback, set_cancelled, JNI_TRUE);
|
||||
}
|
||||
// We expect Java side to call cancelSessions after any error -- thus, `euicc_http_cleanup` is done there
|
||||
// This is so that Java side can access the last HTTP and/or APDU errors when we return.
|
||||
|
|
Loading…
Add table
Reference in a new issue