|
@@ -6,30 +6,23 @@ import android.telephony.euicc.DownloadableSubscription
|
|
|
import android.telephony.euicc.EuiccInfo
|
|
import android.telephony.euicc.EuiccInfo
|
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
import net.typeblog.lpac_jni.LocalProfileInfo
|
|
import net.typeblog.lpac_jni.LocalProfileInfo
|
|
|
-import im.angry.openeuicc.OpenEuiccApplication
|
|
|
|
|
import im.angry.openeuicc.core.EuiccChannel
|
|
import im.angry.openeuicc.core.EuiccChannel
|
|
|
import im.angry.openeuicc.util.*
|
|
import im.angry.openeuicc.util.*
|
|
|
import java.lang.IllegalStateException
|
|
import java.lang.IllegalStateException
|
|
|
|
|
|
|
|
-class OpenEuiccService : EuiccService() {
|
|
|
|
|
|
|
+class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
|
|
|
companion object {
|
|
companion object {
|
|
|
const val TAG = "OpenEuiccService"
|
|
const val TAG = "OpenEuiccService"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private val openEuiccApplication
|
|
|
|
|
- get() = application as OpenEuiccApplication
|
|
|
|
|
-
|
|
|
|
|
private fun findChannel(physicalSlotId: Int): EuiccChannel? =
|
|
private fun findChannel(physicalSlotId: Int): EuiccChannel? =
|
|
|
- openEuiccApplication.euiccChannelManager
|
|
|
|
|
- .findEuiccChannelByPhysicalSlotBlocking(physicalSlotId)
|
|
|
|
|
|
|
+ euiccChannelManager.findEuiccChannelByPhysicalSlotBlocking(physicalSlotId)
|
|
|
|
|
|
|
|
private fun findChannel(slotId: Int, portId: Int): EuiccChannel? =
|
|
private fun findChannel(slotId: Int, portId: Int): EuiccChannel? =
|
|
|
- openEuiccApplication.euiccChannelManager
|
|
|
|
|
- .findEuiccChannelByPortBlocking(slotId, portId)
|
|
|
|
|
|
|
+ euiccChannelManager.findEuiccChannelByPortBlocking(slotId, portId)
|
|
|
|
|
|
|
|
private fun findAllChannels(physicalSlotId: Int): List<EuiccChannel>? =
|
|
private fun findAllChannels(physicalSlotId: Int): List<EuiccChannel>? =
|
|
|
- openEuiccApplication.euiccChannelManager
|
|
|
|
|
- .findAllEuiccChannelsByPhysicalSlotBlocking(physicalSlotId)
|
|
|
|
|
|
|
+ euiccChannelManager.findAllEuiccChannelsByPhysicalSlotBlocking(physicalSlotId)
|
|
|
|
|
|
|
|
override fun onGetEid(slotId: Int): String? =
|
|
override fun onGetEid(slotId: Int): String? =
|
|
|
findChannel(slotId)?.lpa?.eID
|
|
findChannel(slotId)?.lpa?.eID
|
|
@@ -41,7 +34,7 @@ class OpenEuiccService : EuiccService() {
|
|
|
lpa.profiles.any { it.iccid == iccid }
|
|
lpa.profiles.any { it.iccid == iccid }
|
|
|
|
|
|
|
|
private fun ensurePortIsMapped(slotId: Int, portId: Int) {
|
|
private fun ensurePortIsMapped(slotId: Int, portId: Int) {
|
|
|
- val mappings = openEuiccApplication.telephonyManager.simSlotMapping.toMutableList()
|
|
|
|
|
|
|
+ val mappings = telephonyManager.simSlotMapping.toMutableList()
|
|
|
|
|
|
|
|
mappings.firstOrNull { it.physicalSlotIndex == slotId && it.portIndex == portId }?.let {
|
|
mappings.firstOrNull { it.physicalSlotIndex == slotId && it.portIndex == portId }?.let {
|
|
|
throw IllegalStateException("Slot $slotId port $portId has already been mapped")
|
|
throw IllegalStateException("Slot $slotId port $portId has already been mapped")
|
|
@@ -57,14 +50,14 @@ class OpenEuiccService : EuiccService() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- openEuiccApplication.telephonyManager.simSlotMapping = mappings
|
|
|
|
|
|
|
+ telephonyManager.simSlotMapping = mappings
|
|
|
return
|
|
return
|
|
|
} catch (_: Exception) {
|
|
} catch (_: Exception) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Sometimes hardware supports one ordering but not the reverse
|
|
// Sometimes hardware supports one ordering but not the reverse
|
|
|
- openEuiccApplication.telephonyManager.simSlotMapping = mappings.reversed()
|
|
|
|
|
|
|
+ telephonyManager.simSlotMapping = mappings.reversed()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun <T> retryWithTimeout(timeoutMillis: Int, backoff: Int = 1000, f: () -> T?): T? {
|
|
private fun <T> retryWithTimeout(timeoutMillis: Int, backoff: Int = 1000, f: () -> T?): T? {
|
|
@@ -233,7 +226,7 @@ class OpenEuiccService : EuiccService() {
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
return RESULT_FIRST_USER
|
|
return RESULT_FIRST_USER
|
|
|
} finally {
|
|
} finally {
|
|
|
- openEuiccApplication.euiccChannelManager.invalidate()
|
|
|
|
|
|
|
+ euiccChannelManager.invalidate()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|