refactor
This commit is contained in:
parent
5988d57735
commit
77a46d5ac6
8 changed files with 25 additions and 16 deletions
|
@ -26,12 +26,12 @@ class OmapiApduInterface(
|
|||
override val valid: Boolean
|
||||
get() = service.isConnected && (this::session.isInitialized && !session.isClosed)
|
||||
|
||||
override var atr: ByteArray? = null
|
||||
private set
|
||||
override fun readATR(): ByteArray {
|
||||
return session.atr?.clone() ?: throw IllegalStateException("atr unavailable")
|
||||
}
|
||||
|
||||
override fun connect() {
|
||||
session = service.getUiccReaderCompat(port.logicalSlotIndex + 1).openSession()
|
||||
atr = session.atr?.clone()
|
||||
}
|
||||
|
||||
override fun disconnect() {
|
||||
|
|
|
@ -101,7 +101,11 @@ class UsbApduInterface(
|
|||
override val valid: Boolean
|
||||
get() = channelId != -1
|
||||
|
||||
override var atr: ByteArray? = null
|
||||
private var atr: ByteArray? = null
|
||||
|
||||
override fun readATR(): ByteArray {
|
||||
return atr?.clone() ?: throw IllegalStateException("atr unavailable")
|
||||
}
|
||||
|
||||
private fun isSuccessResponse(resp: ByteArray): Boolean =
|
||||
resp.size >= 2 && resp[resp.size - 2] == 0x90.toByte() && resp[resp.size - 1] == 0x00.toByte()
|
||||
|
|
|
@ -43,7 +43,6 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
val titleResId: Int,
|
||||
val content: String?,
|
||||
val copiedToastResId: Int? = null,
|
||||
val isEnabled: Boolean = true,
|
||||
)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -95,13 +94,12 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
lifecycleScope.launch {
|
||||
(infoList.adapter!! as EuiccInfoAdapter).euiccInfoItems =
|
||||
euiccChannelManager.withEuiccChannel(logicalSlotId, ::buildEuiccInfoItems)
|
||||
.filter { it.isEnabled }
|
||||
|
||||
swipeRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun buildEuiccInfoItems(channel: EuiccChannel) = buildList {
|
||||
private fun buildEuiccInfoItems(channel: EuiccChannel) = buildList {
|
||||
add(Item(R.string.euicc_info_access_mode, channel.type))
|
||||
add(
|
||||
Item(
|
||||
|
@ -136,12 +134,16 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
}
|
||||
add(Item(R.string.euicc_info_ci_type, getString(resId)))
|
||||
}
|
||||
val atr = try {
|
||||
channel.lpa.readATR().encodeHex()
|
||||
} catch (e: Exception) {
|
||||
getString(R.string.euicc_info_atr_unavailable)
|
||||
}
|
||||
add(
|
||||
Item(
|
||||
R.string.euicc_info_atr,
|
||||
channel.lpa.atr?.encodeHex(),
|
||||
atr,
|
||||
copiedToastResId = R.string.toast_atr_copied,
|
||||
isEnabled = preferenceRepository.developerOptionsEnabledFlow.first()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
<string name="euicc_info_ci_gsma_test">GSMA Test CI</string>
|
||||
<string name="euicc_info_ci_unknown">Unknown eSIM CI</string>
|
||||
<string name="euicc_info_atr">ATR (Answer To Reset)</string>
|
||||
<string name="euicc_info_atr_unavailable">ATR unavailable</string>
|
||||
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
|
|
@ -25,7 +25,9 @@ class TelephonyManagerApduInterface(
|
|||
// just that transactions might return errors or nonsense
|
||||
get() = lastChannel != -1
|
||||
|
||||
override val atr: ByteArray? = null
|
||||
override fun readATR(): ByteArray {
|
||||
throw IllegalStateException("atr unavailable")
|
||||
}
|
||||
|
||||
override fun connect() {
|
||||
// Do nothing
|
||||
|
|
|
@ -18,7 +18,7 @@ interface ApduInterface {
|
|||
val valid: Boolean
|
||||
|
||||
/**
|
||||
* Answer To Reset
|
||||
* Read Answer To Reset
|
||||
*/
|
||||
val atr: ByteArray?
|
||||
fun readATR(): ByteArray
|
||||
}
|
|
@ -17,13 +17,14 @@ interface LocalProfileAssistant {
|
|||
class ProfileNameIsInvalidUTF8Exception() : Exception("Profile name is invalid UTF-8")
|
||||
|
||||
val valid: Boolean
|
||||
val atr: ByteArray?
|
||||
val profiles: List<LocalProfileInfo>
|
||||
val notifications: List<LocalProfileNotification>
|
||||
val eID: String
|
||||
// Extended EuiccInfo for use with LUIs, containing information such as firmware version
|
||||
val euiccInfo2: EuiccInfo2?
|
||||
|
||||
fun readATR(): ByteArray
|
||||
|
||||
/**
|
||||
* Set the max segment size (mss) for all es10x commands. This can help with removable
|
||||
* eUICCs that may run at a baud rate too fast for the modem.
|
||||
|
|
|
@ -102,9 +102,6 @@ class LocalProfileAssistantImpl(
|
|||
false
|
||||
}
|
||||
|
||||
override val atr: ByteArray?
|
||||
get() = apduInterface.atr
|
||||
|
||||
override val profiles: List<LocalProfileInfo>
|
||||
@Synchronized
|
||||
get() {
|
||||
|
@ -190,6 +187,8 @@ class LocalProfileAssistantImpl(
|
|||
return ret
|
||||
}
|
||||
|
||||
override fun readATR() = apduInterface.readATR()
|
||||
|
||||
@Synchronized
|
||||
override fun enableProfile(iccid: String, refresh: Boolean): Boolean =
|
||||
LpacJni.es10cEnableProfile(contextHandle, iccid, refresh) == 0
|
||||
|
|
Loading…
Reference in a new issue