Compare commits

..

No commits in common. "ef622740573d3d2fea0cac410a3e0f9991b096e5" and "d54fcf2589c4e94dc041b4d5d857a56a8e7dbd80" have entirely different histories.

4 changed files with 2 additions and 112 deletions

View file

@ -166,12 +166,7 @@ open class DefaultEuiccChannelManager(
): R {
val channel = findEuiccChannelByPortBlocking(physicalSlotId, portId)
?: throw EuiccChannelManager.EuiccChannelNotFoundException()
val wrapper = EuiccChannelWrapper(channel)
try {
return fn(wrapper)
} finally {
wrapper.invalidateWrapper()
}
return fn(channel)
}
override suspend fun waitForReconnect(physicalSlotId: Int, portId: Int, timeoutMillis: Long) {

View file

@ -68,8 +68,7 @@ interface EuiccChannelManager {
/**
* Find a EuiccChannel by its slot and port, then run a callback with a reference to it.
* The reference is not supposed to be held outside of the callback. This is enforced via
* a wrapper object.
* The reference is not supposed to be held outside of the callback.
*
* If a channel for that slot / port is not found, EuiccChannelNotFoundException is thrown
*/

View file

@ -1,41 +0,0 @@
package im.angry.openeuicc.core
import im.angry.openeuicc.util.*
import net.typeblog.lpac_jni.LocalProfileAssistant
class EuiccChannelWrapper(orig: EuiccChannel) : EuiccChannel {
private var _inner: EuiccChannel? = orig
private val channel: EuiccChannel
get() {
if (_inner == null) {
throw IllegalStateException("This wrapper has been invalidated")
}
return _inner!!
}
override val port: UiccPortInfoCompat
get() = channel.port
override val slotId: Int
get() = channel.slotId
override val logicalSlotId: Int
get() = channel.logicalSlotId
override val portId: Int
get() = channel.portId
private val lpaDelegate = lazy {
LocalProfileAssistantWrapper(channel.lpa)
}
override val lpa: LocalProfileAssistant by lpaDelegate
override val valid: Boolean
get() = channel.valid
override fun close() = channel.close()
fun invalidateWrapper() {
_inner = null
if (lpaDelegate.isInitialized()) {
(lpa as LocalProfileAssistantWrapper).invalidateWrapper()
}
}
}

View file

@ -1,63 +0,0 @@
package im.angry.openeuicc.core
import net.typeblog.lpac_jni.EuiccInfo2
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.LocalProfileInfo
import net.typeblog.lpac_jni.LocalProfileNotification
import net.typeblog.lpac_jni.ProfileDownloadCallback
class LocalProfileAssistantWrapper(orig: LocalProfileAssistant) :
LocalProfileAssistant {
private var _inner: LocalProfileAssistant? = orig
private val lpa: LocalProfileAssistant
get() {
if (_inner == null) {
throw IllegalStateException("This wrapper has been invalidated")
}
return _inner!!
}
override val valid: Boolean
get() = lpa.valid
override val profiles: List<LocalProfileInfo>
get() = lpa.profiles
override val notifications: List<LocalProfileNotification>
get() = lpa.notifications
override val eID: String
get() = lpa.eID
override val euiccInfo2: EuiccInfo2?
get() = lpa.euiccInfo2
override fun setEs10xMss(mss: Byte) = lpa.setEs10xMss(mss)
override fun enableProfile(iccid: String, refresh: Boolean): Boolean =
lpa.enableProfile(iccid, refresh)
override fun disableProfile(iccid: String, refresh: Boolean): Boolean =
lpa.disableProfile(iccid, refresh)
override fun deleteProfile(iccid: String): Boolean = lpa.deleteProfile(iccid)
override fun downloadProfile(
smdp: String,
matchingId: String?,
imei: String?,
confirmationCode: String?,
callback: ProfileDownloadCallback
): Boolean = lpa.downloadProfile(smdp, matchingId, imei, confirmationCode, callback)
override fun deleteNotification(seqNumber: Long): Boolean = lpa.deleteNotification(seqNumber)
override fun handleNotification(seqNumber: Long): Boolean = lpa.handleNotification(seqNumber)
override fun setNickname(iccid: String, nickname: String): Boolean =
lpa.setNickname(iccid, nickname)
override fun close() = lpa.close()
fun invalidateWrapper() {
_inner = null
}
}