Compare commits
3 commits
d7214141e6
...
96bc9865ff
Author | SHA1 | Date | |
---|---|---|---|
96bc9865ff | |||
dcae65011e | |||
1c4263a47a |
4 changed files with 42 additions and 31 deletions
|
@ -82,12 +82,12 @@
|
|||
<string name="download_wizard_progress_step_downloading">Downloading eSIM profile</string>
|
||||
<string name="download_wizard_progress_step_finalizing">Loading eSIM profile into storage</string>
|
||||
<string name="download_wizard_diagnostics">Error diagnostics</string>
|
||||
<string name="download_wizard_diagnostics_last_http_status">Last HTTP status: %d</string>
|
||||
<string name="download_wizard_diagnostics_last_http_response">Last HTTP response:</string>
|
||||
<string name="download_wizard_diagnostics_last_http_status">Last HTTP status (from server): %d</string>
|
||||
<string name="download_wizard_diagnostics_last_http_response">Last HTTP response (from server):</string>
|
||||
<string name="download_wizard_diagnostics_last_http_exception">Last HTTP exception:</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response">Last APDU response: %s</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response_success">Last APDU response is successful</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response_fail">Last APDU response is a failure</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response">Last APDU response (from SIM): %s</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response_success">Last APDU response (from SIM) is successful</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_response_fail">Last APDU response (from SIM) is a failure</string>
|
||||
<string name="download_wizard_diagnostics_last_apdu_exception">Last APDU exception:</string>
|
||||
|
||||
<string name="profile_rename_new_name">New nickname</string>
|
||||
|
|
|
@ -26,20 +26,6 @@ interface HttpInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The last HTTP response we have received from the SM-DP+ server.
|
||||
*
|
||||
* This is intended for error diagnosis. However, note that most SM-DP+ servers
|
||||
* respond with 200 even when there is an error. This needs to be taken into
|
||||
* account when designing UI.
|
||||
*/
|
||||
val lastHttpResponse: HttpResponse?
|
||||
|
||||
/**
|
||||
* The last exception that has been thrown during a HTTP connection
|
||||
*/
|
||||
val lastHttpException: Exception?
|
||||
|
||||
fun transmit(url: String, tx: ByteArray, headers: Array<String>): HttpResponse
|
||||
// The LPA is supposed to pass in a list of pkIds supported by the eUICC.
|
||||
// HttpInterface is responsible for providing TrustManager implementations that
|
||||
|
|
|
@ -23,9 +23,6 @@ class HttpInterfaceImpl(
|
|||
|
||||
private lateinit var trustManagers: Array<TrustManager>
|
||||
|
||||
override var lastHttpResponse: HttpInterface.HttpResponse? = null
|
||||
override var lastHttpException: Exception? = null
|
||||
|
||||
override fun transmit(
|
||||
url: String,
|
||||
tx: ByteArray,
|
||||
|
@ -76,16 +73,9 @@ class HttpInterfaceImpl(
|
|||
}
|
||||
}
|
||||
|
||||
return HttpInterface.HttpResponse(conn.responseCode, bytes).also {
|
||||
lastHttpResponse = it
|
||||
}
|
||||
return HttpInterface.HttpResponse(conn.responseCode, bytes)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
// Reset response to null because there's no response here
|
||||
lastHttpResponse = null
|
||||
lastHttpException = e
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.typeblog.lpac_jni.LpacJni
|
|||
import net.typeblog.lpac_jni.ApduInterface
|
||||
import net.typeblog.lpac_jni.EuiccInfo2
|
||||
import net.typeblog.lpac_jni.HttpInterface
|
||||
import net.typeblog.lpac_jni.HttpInterface.HttpResponse
|
||||
import net.typeblog.lpac_jni.LocalProfileAssistant
|
||||
import net.typeblog.lpac_jni.LocalProfileInfo
|
||||
import net.typeblog.lpac_jni.LocalProfileNotification
|
||||
|
@ -12,7 +13,7 @@ import net.typeblog.lpac_jni.ProfileDownloadCallback
|
|||
|
||||
class LocalProfileAssistantImpl(
|
||||
rawApduInterface: ApduInterface,
|
||||
private val httpInterface: HttpInterface
|
||||
rawHttpInterface: HttpInterface
|
||||
): LocalProfileAssistant {
|
||||
companion object {
|
||||
private const val TAG = "LocalProfileAssistantImpl"
|
||||
|
@ -29,6 +30,7 @@ class LocalProfileAssistantImpl(
|
|||
override fun transmit(tx: ByteArray): ByteArray =
|
||||
try {
|
||||
apduInterface.transmit(tx).also {
|
||||
lastApduException = null
|
||||
lastApduResponse = it
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -38,7 +40,40 @@ class LocalProfileAssistantImpl(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same for HTTP for diagnostics
|
||||
*/
|
||||
private class HttpInterfaceWrapper(val httpInterface: HttpInterface) :
|
||||
HttpInterface by httpInterface {
|
||||
/**
|
||||
* The last HTTP response we have received from the SM-DP+ server.
|
||||
*
|
||||
* This is intended for error diagnosis. However, note that most SM-DP+ servers
|
||||
* respond with 200 even when there is an error. This needs to be taken into
|
||||
* account when designing UI.
|
||||
*/
|
||||
var lastHttpResponse: HttpResponse? = null
|
||||
|
||||
/**
|
||||
* The last exception that has been thrown during a HTTP connection
|
||||
*/
|
||||
var lastHttpException: Exception? = null
|
||||
|
||||
override fun transmit(url: String, tx: ByteArray, headers: Array<String>): HttpResponse =
|
||||
try {
|
||||
httpInterface.transmit(url, tx, headers).also {
|
||||
lastHttpException = null
|
||||
lastHttpResponse = it
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
lastHttpResponse = null
|
||||
lastHttpException = e
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
private val apduInterface = ApduInterfaceWrapper(rawApduInterface)
|
||||
private val httpInterface = HttpInterfaceWrapper(rawHttpInterface)
|
||||
|
||||
private var finalized = false
|
||||
private var contextHandle: Long = LpacJni.createContext(apduInterface, httpInterface)
|
||||
|
|
Loading…
Add table
Reference in a new issue