Browse Source

Move some functions to LPAUtils

Peter Cai 1 year ago
parent
commit
2b3f042e39

+ 8 - 0
app-common/src/main/java/im/angry/openeuicc/util/LPAUtils.kt

@@ -1,16 +1,24 @@
 package im.angry.openeuicc.util
 package im.angry.openeuicc.util
 
 
+import im.angry.openeuicc.core.EuiccChannel
 import net.typeblog.lpac_jni.LocalProfileAssistant
 import net.typeblog.lpac_jni.LocalProfileAssistant
 import net.typeblog.lpac_jni.LocalProfileInfo
 import net.typeblog.lpac_jni.LocalProfileInfo
 
 
 val LocalProfileInfo.displayName: String
 val LocalProfileInfo.displayName: String
     get() = nickName.ifEmpty { name }
     get() = nickName.ifEmpty { name }
 
 
+
+val LocalProfileInfo.isEnabled: Boolean
+    get() = state == LocalProfileInfo.State.Enabled
+
 val List<LocalProfileInfo>.operational: List<LocalProfileInfo>
 val List<LocalProfileInfo>.operational: List<LocalProfileInfo>
     get() = filter {
     get() = filter {
         it.profileClass == LocalProfileInfo.Clazz.Operational
         it.profileClass == LocalProfileInfo.Clazz.Operational
     }
     }
 
 
+val List<EuiccChannel>.hasMultipleChips: Boolean
+    get() = distinctBy { it.slotId }.size > 1
+
 fun LocalProfileAssistant.disableActiveProfileWithUndo(): () -> Unit =
 fun LocalProfileAssistant.disableActiveProfileWithUndo(): () -> Unit =
     profiles.find { it.state == LocalProfileInfo.State.Enabled }?.let {
     profiles.find { it.state == LocalProfileInfo.State.Enabled }?.let {
         disableProfile(it.iccid)
         disableProfile(it.iccid)

+ 0 - 8
app-common/src/main/java/im/angry/openeuicc/util/Utils.kt

@@ -11,14 +11,12 @@ import com.google.zxing.RGBLuminanceSource
 import com.google.zxing.common.HybridBinarizer
 import com.google.zxing.common.HybridBinarizer
 import com.google.zxing.qrcode.QRCodeReader
 import com.google.zxing.qrcode.QRCodeReader
 import im.angry.openeuicc.OpenEuiccApplication
 import im.angry.openeuicc.OpenEuiccApplication
-import im.angry.openeuicc.core.EuiccChannel
 import im.angry.openeuicc.di.AppContainer
 import im.angry.openeuicc.di.AppContainer
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.runBlocking
 import kotlinx.coroutines.runBlocking
 import kotlinx.coroutines.sync.Mutex
 import kotlinx.coroutines.sync.Mutex
 import kotlinx.coroutines.sync.withLock
 import kotlinx.coroutines.sync.withLock
 import kotlinx.coroutines.withContext
 import kotlinx.coroutines.withContext
-import net.typeblog.lpac_jni.LocalProfileInfo
 import kotlin.RuntimeException
 import kotlin.RuntimeException
 import kotlin.coroutines.resume
 import kotlin.coroutines.resume
 import kotlin.coroutines.resumeWithException
 import kotlin.coroutines.resumeWithException
@@ -60,12 +58,6 @@ interface OpenEuiccContextMarker {
         get() = appContainer.telephonyManager
         get() = appContainer.telephonyManager
 }
 }
 
 
-val LocalProfileInfo.isEnabled: Boolean
-    get() = state == LocalProfileInfo.State.Enabled
-
-val List<EuiccChannel>.hasMultipleChips: Boolean
-    get() = distinctBy { it.slotId }.size > 1
-
 // Create an instance of OMAPI SEService in a manner that "makes sense" without unpredictable callbacks
 // Create an instance of OMAPI SEService in a manner that "makes sense" without unpredictable callbacks
 suspend fun connectSEService(context: Context): SEService = suspendCoroutine { cont ->
 suspend fun connectSEService(context: Context): SEService = suspendCoroutine { cont ->
     // Use a Mutex to make sure the continuation is run *after* the "service" variable is assigned
     // Use a Mutex to make sure the continuation is run *after* the "service" variable is assigned