diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 61f4db4..1c5ab05 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,16 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app-common/src/main/res/values-ja/strings.xml b/app-common/src/main/res/values-ja/strings.xml
index 72b88a8..925a5a2 100644
--- a/app-common/src/main/res/values-ja/strings.xml
+++ b/app-common/src/main/res/values-ja/strings.xml
@@ -114,13 +114,13 @@
あなたは開発者になりました!
設定
通知
- eSIM のプロファイル操作により、通信事業者に通知が送信されます。必要に応じてこの動作を微調整できます。
+ eSIM のプロファイル操作により、通信事業者に通知が送信されます。ここでは、どのタイプの通知を送信するのかを微調整できます。
ダウンロード
- プロファイルをダウンロード中の通知を送信します
+ プロファイルのダウンロード済みの通知を送信します
削除
- プロファイルを削除中の通知を送信します
- 切り替え中
- プロファイルを切り替え中の通知を送信します\nこのタイプの通知は信頼できないことに注意してください。
+ プロファイルの削除済みの通知を送信します
+ 切り替え
+ プロファイルの切り替え済みの通知を送信します\nこのタイプの通知は有効化しても必ず送信するとは限らないことに注意してください。
高度な設定
有効なプロファイルの無効化と削除を許可する
デフォルトでは、このアプリでデバイスに挿入された取り外し可能な eSIM の有効なプロファイルを無効化することを防いでいます。なぜなのかというと時々アクセスができなくなるからです。\nこのチェックボックスを ON にすることで、この保護機能を解除します。
@@ -136,4 +136,8 @@
情報
アプリバージョン
ソースコード
+ 言語
+ アプリの言語を選択
+ すべてのプロファイルを表示
+ プロダクション以外のプロファイルも表示する
diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml
index 174b18c..d0813d2 100644
--- a/app-common/src/main/res/values/strings.xml
+++ b/app-common/src/main/res/values/strings.xml
@@ -147,14 +147,14 @@
Verbose Logging
Enable verbose logs, which may contain sensitive information. Only share your logs with someone you trust after turning this on.
Language
- Select current language
+ Select app language
Logs
View recent debug logs of the application
Developer Options
Experimental Download Wizard
Enable the experimental new download wizard. Note that it is not fully working yet.
Show unfiltered profile list
- Display any profile class in the list
+ Include non-production profiles in the list
Ignore SM-DP+ TLS certificate
Ignore SM-DP+ TLS certificate, allow any RSP
Info
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 f9a2f90..1e64c69 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
@@ -30,6 +30,8 @@ internal object LpacJni {
external fun downloadProfile(handle: Long, smdp: String, matchingId: String?, imei: String?,
confirmationCode: String?, callback: ProfileDownloadCallback): Int
external fun handleNotification(handle: Long, seqNumber: Long): Int
+ // Cancel any ongoing es9p and/or es10b sessions
+ external fun cancelSessions(handle: Long)
// es10cex (actually part of es10b)
external fun es10cexGetEuiccInfo2(handle: Long): Long
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 70606d9..4dbb181 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
@@ -212,12 +212,18 @@ class LocalProfileAssistantImpl(
)
if (res != 0) {
- throw LocalProfileAssistant.ProfileDownloadException(
+ // Construct the error now to store any error information we _can_ access
+ val err = LocalProfileAssistant.ProfileDownloadException(
httpInterface.lastHttpResponse,
httpInterface.lastHttpException,
apduInterface.lastApduResponse,
apduInterface.lastApduException,
)
+
+ // Cancel sessions if possible. This will overwrite recorded errors from HTTP and APDU interfaces.
+ LpacJni.cancelSessions(contextHandle)
+
+ throw err
}
}
diff --git a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-download.c b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-download.c
index 91676da..f63585a 100644
--- a/libs/lpac-jni/src/main/jni/lpac-jni/lpac-download.c
+++ b/libs/lpac-jni/src/main/jni/lpac-jni/lpac-download.c
@@ -82,42 +82,55 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
(*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);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ES10B_ERROR_REASON_UNDEFINED;
goto out;
+ }
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_connecting);
ret = es9p_initiate_authentication(ctx);
syslog(LOG_INFO, "es9p_initiate_authentication %d", ret);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ES10B_ERROR_REASON_UNDEFINED;
goto out;
+ }
(*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);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ES10B_ERROR_REASON_UNDEFINED;
goto out;
+ }
ret = es9p_authenticate_client(ctx);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ES10B_ERROR_REASON_UNDEFINED;
goto out;
+ }
(*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);
- if (ret < 0)
+ if (ret < 0) {
+ ret = -ES10B_ERROR_REASON_UNDEFINED;
goto out;
+ }
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);
syslog(LOG_INFO, "es10b_load_bound_profile_package %d, reason %d", ret, es10b_load_bound_profile_package_result.errorReason);
+ if (ret < 0) {
+ ret = - (int) es10b_load_bound_profile_package_result.errorReason;
+ }
out:
- euicc_http_cleanup(ctx);
+ // 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.
if (_confirmation_code != NULL)
(*env)->ReleaseStringUTFChars(env, confirmation_code, _confirmation_code);
if (_matching_id != NULL)
@@ -127,3 +140,12 @@ Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, j
(*env)->ReleaseStringUTFChars(env, imei, _imei);
return ret;
}
+
+
+JNIEXPORT void JNICALL
+Java_net_typeblog_lpac_1jni_LpacJni_cancelSessions(JNIEnv *env, jobject thiz, jlong handle) {
+ struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
+ es9p_cancel_session(ctx);
+ es10b_cancel_session(ctx, ES10B_CANCEL_SESSION_REASON_UNDEFINED);
+ euicc_http_cleanup(ctx);
+}
\ No newline at end of file