|
@@ -1,24 +1,47 @@
|
|
|
package im.angry.openeuicc.core
|
|
package im.angry.openeuicc.core
|
|
|
|
|
|
|
|
-import android.telephony.IccOpenLogicalChannelResponse
|
|
|
|
|
import android.telephony.TelephonyManager
|
|
import android.telephony.TelephonyManager
|
|
|
-import android.util.Log
|
|
|
|
|
-import com.truphone.lpa.LocalProfileAssistant
|
|
|
|
|
-import com.truphone.lpa.impl.LocalProfileAssistantImpl
|
|
|
|
|
-import im.angry.openeuicc.util.*
|
|
|
|
|
-import java.lang.Exception
|
|
|
|
|
|
|
+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 TelephonyManagerChannel private constructor(
|
|
|
|
|
|
|
+class TelephonyManagerApduInterface(
|
|
|
|
|
+ private val info: EuiccChannelInfo,
|
|
|
|
|
+ private val tm: TelephonyManager
|
|
|
|
|
+): ApduInterface {
|
|
|
|
|
+ override fun connect() {
|
|
|
|
|
+ TODO("Not yet implemented")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun disconnect() {
|
|
|
|
|
+ TODO("Not yet implemented")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun logicalChannelOpen(aid: ByteArray): Int {
|
|
|
|
|
+ TODO("Not yet implemented")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun logicalChannelClose(handle: Int) {
|
|
|
|
|
+ TODO("Not yet implemented")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun transmit(tx: ByteArray): ByteArray {
|
|
|
|
|
+ TODO("Not yet implemented")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class TelephonyManagerChannel(
|
|
|
info: EuiccChannelInfo,
|
|
info: EuiccChannelInfo,
|
|
|
- private val tm: TelephonyManager,
|
|
|
|
|
- private val channelId: Int
|
|
|
|
|
|
|
+ private val tm: TelephonyManager
|
|
|
) : EuiccChannel(info) {
|
|
) : EuiccChannel(info) {
|
|
|
companion object {
|
|
companion object {
|
|
|
private const val TAG = "TelephonyManagerApduChannel"
|
|
private const val TAG = "TelephonyManagerApduChannel"
|
|
|
private const val EUICC_APP_ID = "A0000005591010FFFFFFFF8900000100"
|
|
private const val EUICC_APP_ID = "A0000005591010FFFFFFFF8900000100"
|
|
|
|
|
|
|
|
// TODO: On Tiramisu, we need to specify the portId also if we want MEP support
|
|
// TODO: On Tiramisu, we need to specify the portId also if we want MEP support
|
|
|
- fun tryConnect(tm: TelephonyManager, info: EuiccChannelInfo): TelephonyManagerChannel? {
|
|
|
|
|
|
|
+ /*fun tryConnect(tm: TelephonyManager, info: EuiccChannelInfo): TelephonyManagerChannel? {
|
|
|
try {
|
|
try {
|
|
|
val channel = tm.iccOpenLogicalChannelBySlot(info.slotId, EUICC_APP_ID, 0)
|
|
val channel = tm.iccOpenLogicalChannelBySlot(info.slotId, EUICC_APP_ID, 0)
|
|
|
if (channel.status != IccOpenLogicalChannelResponse.STATUS_NO_ERROR || channel.channel == IccOpenLogicalChannelResponse.INVALID_CHANNEL) {
|
|
if (channel.status != IccOpenLogicalChannelResponse.STATUS_NO_ERROR || channel.channel == IccOpenLogicalChannelResponse.INVALID_CHANNEL) {
|
|
@@ -34,16 +57,15 @@ class TelephonyManagerChannel private constructor(
|
|
|
Log.e(TAG, Log.getStackTraceString(e))
|
|
Log.e(TAG, Log.getStackTraceString(e))
|
|
|
return null
|
|
return null
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- override val lpa: LocalProfileAssistant by lazy {
|
|
|
|
|
- LocalProfileAssistantImpl(TelephonyManagerApduChannel(tm, slotId, channelId))
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ override val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(
|
|
|
|
|
+ TelephonyManagerApduInterface(info, tm),
|
|
|
|
|
+ HttpInterfaceImpl()
|
|
|
|
|
+ )
|
|
|
override val valid: Boolean
|
|
override val valid: Boolean
|
|
|
get() = true // TODO: Fix this
|
|
get() = true // TODO: Fix this
|
|
|
|
|
|
|
|
- override fun close() {
|
|
|
|
|
- tm.iccCloseLogicalChannelBySlot(slotId, channelId)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ override fun close() = lpa.close()
|
|
|
}
|
|
}
|