Browse Source

lpac-jni: Mark network-related LPA methods as synchronized

These methods rely on non-thread-safe internal states within lpac's
context.
Peter Cai 1 year ago
parent
commit
62e3e41c52

+ 2 - 0
libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/impl/LocalProfileAssistantImpl.kt

@@ -115,6 +115,7 @@ class LocalProfileAssistantImpl(
         return LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0
         return LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0
     }
     }
 
 
+    @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
@@ -123,6 +124,7 @@ class LocalProfileAssistantImpl(
     override fun deleteNotification(seqNumber: Long): Boolean =
     override fun deleteNotification(seqNumber: Long): Boolean =
         LpacJni.es10bDeleteNotification(contextHandle, seqNumber) == 0
         LpacJni.es10bDeleteNotification(contextHandle, seqNumber) == 0
 
 
+    @Synchronized
     override fun handleNotification(seqNumber: Long): Boolean =
     override fun handleNotification(seqNumber: Long): Boolean =
         LpacJni.handleNotification(contextHandle, seqNumber).also {
         LpacJni.handleNotification(contextHandle, seqNumber).also {
             Log.d(TAG, "handleNotification $seqNumber = $it")
             Log.d(TAG, "handleNotification $seqNumber = $it")