From 5300178a0ef14f11882f5e7f8743c9db9dc79aeb Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sun, 14 Jul 2024 20:45:46 -0400 Subject: [PATCH] lpac-jni: Kill profiles cache, and stop crashing when null This is no longer needed because we are using euiccInfo2 to check validity --- .../impl/LocalProfileAssistantImpl.kt | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt index 79a35ec..361c594 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt @@ -41,11 +41,8 @@ class LocalProfileAssistantImpl( false } - private var _profiles: List? = null override val profiles: List - get() = (_profiles ?: LpacJni.es10cGetProfilesInfo(contextHandle)!!.asList()).also { - _profiles = it - } + get() = LpacJni.es10cGetProfilesInfo(contextHandle)?.asList() ?: listOf() override val notifications: List get() = @@ -59,26 +56,25 @@ class LocalProfileAssistantImpl( get() = LpacJni.es10cexGetEuiccInfo2(contextHandle) override fun enableProfile(iccid: String, refresh: Boolean): Boolean = - (LpacJni.es10cEnableProfile(contextHandle, iccid, refresh) == 0).also { - _profiles = null - } + LpacJni.es10cEnableProfile(contextHandle, iccid, refresh) == 0 override fun disableProfile(iccid: String, refresh: Boolean): Boolean = - (LpacJni.es10cDisableProfile(contextHandle, iccid, refresh) == 0).also { - _profiles = null - } + LpacJni.es10cDisableProfile(contextHandle, iccid, refresh) == 0 override fun deleteProfile(iccid: String): Boolean = - (LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0).also { - _profiles = null - } + LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0 @Synchronized override fun downloadProfile(smdp: String, matchingId: String?, imei: String?, confirmationCode: String?, callback: ProfileDownloadCallback): Boolean { - return (LpacJni.downloadProfile(contextHandle, smdp, matchingId, imei, confirmationCode, callback) == 0).also { - _profiles = null - } + return LpacJni.downloadProfile( + contextHandle, + smdp, + matchingId, + imei, + confirmationCode, + callback + ) == 0 } override fun deleteNotification(seqNumber: Long): Boolean = @@ -91,9 +87,7 @@ class LocalProfileAssistantImpl( } == 0 override fun setNickname(iccid: String, nickname: String): Boolean = - (LpacJni.es10cSetNickname(contextHandle, iccid, nickname) == 0).also { - _profiles = null - } + LpacJni.es10cSetNickname(contextHandle, iccid, nickname) == 0 @Synchronized override fun close() {