lpac-jni: Avoid reloading profiles from card every time
All checks were successful
/ build-debug (push) Successful in 5m57s
All checks were successful
/ build-debug (push) Successful in 5m57s
Some cards may run at a low baud rate which causes issues
This commit is contained in:
parent
3869374140
commit
2d312f2216
|
@ -20,6 +20,7 @@ class LocalProfileAssistantImpl(
|
||||||
|
|
||||||
private var finalized = false
|
private var finalized = false
|
||||||
private var contextHandle: Long = LpacJni.createContext(apduInterface, httpInterface)
|
private var contextHandle: Long = LpacJni.createContext(apduInterface, httpInterface)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (LpacJni.euiccInit(contextHandle) < 0) {
|
if (LpacJni.euiccInit(contextHandle) < 0) {
|
||||||
throw IllegalArgumentException("Failed to initialize LPA")
|
throw IllegalArgumentException("Failed to initialize LPA")
|
||||||
|
@ -40,8 +41,11 @@ class LocalProfileAssistantImpl(
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var _profiles: List<LocalProfileInfo>? = null
|
||||||
override val profiles: List<LocalProfileInfo>
|
override val profiles: List<LocalProfileInfo>
|
||||||
get() = LpacJni.es10cGetProfilesInfo(contextHandle)!!.asList()
|
get() = (_profiles ?: LpacJni.es10cGetProfilesInfo(contextHandle)!!.asList()).also {
|
||||||
|
_profiles = it
|
||||||
|
}
|
||||||
|
|
||||||
override val notifications: List<LocalProfileNotification>
|
override val notifications: List<LocalProfileNotification>
|
||||||
get() =
|
get() =
|
||||||
|
@ -55,19 +59,26 @@ class LocalProfileAssistantImpl(
|
||||||
get() = LpacJni.es10cexGetEuiccInfo2(contextHandle)
|
get() = LpacJni.es10cexGetEuiccInfo2(contextHandle)
|
||||||
|
|
||||||
override fun enableProfile(iccid: String): Boolean =
|
override fun enableProfile(iccid: String): Boolean =
|
||||||
LpacJni.es10cEnableProfile(contextHandle, iccid) == 0
|
(LpacJni.es10cEnableProfile(contextHandle, iccid) == 0).also {
|
||||||
|
_profiles = null
|
||||||
|
}
|
||||||
|
|
||||||
override fun disableProfile(iccid: String): Boolean =
|
override fun disableProfile(iccid: String): Boolean =
|
||||||
LpacJni.es10cDisableProfile(contextHandle, iccid) == 0
|
(LpacJni.es10cDisableProfile(contextHandle, iccid) == 0).also {
|
||||||
|
_profiles = null
|
||||||
|
}
|
||||||
|
|
||||||
override fun deleteProfile(iccid: String): Boolean {
|
override fun deleteProfile(iccid: String): Boolean =
|
||||||
return LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0
|
(LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0).also {
|
||||||
|
_profiles = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun downloadProfile(smdp: String, matchingId: String?, imei: String?,
|
override fun downloadProfile(smdp: String, matchingId: String?, imei: String?,
|
||||||
confirmationCode: String?, callback: ProfileDownloadCallback): Boolean {
|
confirmationCode: String?, callback: ProfileDownloadCallback): Boolean {
|
||||||
return LpacJni.downloadProfile(contextHandle, smdp, matchingId, imei, confirmationCode, callback) == 0
|
return (LpacJni.downloadProfile(contextHandle, smdp, matchingId, imei, confirmationCode, callback) == 0).also {
|
||||||
|
_profiles = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteNotification(seqNumber: Long): Boolean =
|
override fun deleteNotification(seqNumber: Long): Boolean =
|
||||||
|
@ -79,8 +90,9 @@ class LocalProfileAssistantImpl(
|
||||||
Log.d(TAG, "handleNotification $seqNumber = $it")
|
Log.d(TAG, "handleNotification $seqNumber = $it")
|
||||||
} == 0
|
} == 0
|
||||||
|
|
||||||
override fun setNickname(iccid: String, nickname: String): Boolean {
|
override fun setNickname(iccid: String, nickname: String): Boolean =
|
||||||
return LpacJni.es10cSetNickname(contextHandle, iccid, nickname) == 0
|
(LpacJni.es10cSetNickname(contextHandle, iccid, nickname) == 0).also {
|
||||||
|
_profiles = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
|
Loading…
Reference in a new issue