refactor: EuiccChannel is not abstract
All checks were successful
/ build-debug (push) Successful in 4m19s

This commit is contained in:
Peter Cai 2024-03-17 11:19:07 -04:00
parent 3a0d805eb2
commit 6977a32e80
5 changed files with 11 additions and 33 deletions

View file

@ -24,7 +24,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
Log.i(DefaultEuiccChannelManager.TAG, "Trying OMAPI for physical slot ${port.card.physicalSlotIndex}")
try {
return OmapiChannel(seService!!, port)
return EuiccChannel(port, OmapiApduInterface(seService!!, port))
} catch (e: IllegalArgumentException) {
// Failed
Log.w(

View file

@ -1,16 +1,21 @@
package im.angry.openeuicc.core
import im.angry.openeuicc.util.*
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
abstract class EuiccChannel(
val port: UiccPortInfoCompat
class EuiccChannel(
val port: UiccPortInfoCompat,
apduInterface: ApduInterface,
) {
val slotId = port.card.physicalSlotIndex // PHYSICAL slot
val logicalSlotId = port.logicalSlotIndex
val portId = port.portIndex
abstract val lpa: LocalProfileAssistant
val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(apduInterface, HttpInterfaceImpl())
val valid: Boolean
get() = lpa.valid

View file

@ -5,9 +5,6 @@ import android.se.omapi.SEService
import android.se.omapi.Session
import im.angry.openeuicc.util.*
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
class OmapiApduInterface(
private val service: SEService,
@ -47,13 +44,4 @@ class OmapiApduInterface(
return lastChannel.transmit(tx)
}
}
class OmapiChannel(
service: SEService,
port: UiccPortInfoCompat,
) : EuiccChannel(port) {
override val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(
OmapiApduInterface(service, port),
HttpInterfaceImpl())
}
}

View file

@ -26,9 +26,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
"Trying TelephonyManager for slot ${port.card.physicalSlotIndex} port ${port.portIndex}"
)
try {
return TelephonyManagerChannel(
port, tm
)
return EuiccChannel(port, TelephonyManagerApduInterface(port, tm))
} catch (e: IllegalArgumentException) {
// Failed
Log.w(

View file

@ -3,10 +3,7 @@ package im.angry.openeuicc.core
import android.telephony.IccOpenLogicalChannelResponse
import android.telephony.TelephonyManager
import im.angry.openeuicc.util.*
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
class TelephonyManagerApduInterface(
private val port: UiccPortInfoCompat,
@ -54,14 +51,4 @@ class TelephonyManagerApduInterface(
cla, instruction, p1, p2, p3, p4)?.decodeHex() ?: byteArrayOf()
}
}
class TelephonyManagerChannel(
port: UiccPortInfoCompat,
private val tm: TelephonyManager
) : EuiccChannel(port) {
override val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(
TelephonyManagerApduInterface(port, tm),
HttpInterfaceImpl()
)
}