Browse Source

EuiccChannelManager: Remove some unused methods

Peter Cai 1 year ago
parent
commit
5dacb75717

+ 1 - 24
app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt

@@ -113,25 +113,7 @@ open class DefaultEuiccChannelManager(
             findEuiccChannelBySlot(logicalSlotId)
         }
 
-    override fun findEuiccChannelByPhysicalSlotBlocking(physicalSlotId: Int): EuiccChannel? =
-        runBlocking {
-            withContext(Dispatchers.IO) {
-                if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
-                    return@withContext usbChannel
-                }
-
-                for (card in uiccCards) {
-                    if (card.physicalSlotIndex != physicalSlotId) continue
-                    for (port in card.ports) {
-                        tryOpenEuiccChannel(port)?.let { return@withContext it }
-                    }
-                }
-
-                null
-            }
-        }
-
-    override suspend fun findAllEuiccChannelsByPhysicalSlot(physicalSlotId: Int): List<EuiccChannel>? {
+    private suspend fun findAllEuiccChannelsByPhysicalSlot(physicalSlotId: Int): List<EuiccChannel>? {
         if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
             return usbChannel?.let { listOf(it) }
         }
@@ -144,11 +126,6 @@ open class DefaultEuiccChannelManager(
         return null
     }
 
-    override fun findAllEuiccChannelsByPhysicalSlotBlocking(physicalSlotId: Int): List<EuiccChannel>? =
-        runBlocking {
-            findAllEuiccChannelsByPhysicalSlot(physicalSlotId)
-        }
-
     override suspend fun findEuiccChannelByPort(physicalSlotId: Int, portId: Int): EuiccChannel? =
         withContext(Dispatchers.IO) {
             if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {

+ 0 - 14
app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt

@@ -52,20 +52,6 @@ interface EuiccChannelManager {
      */
     fun findEuiccChannelBySlotBlocking(logicalSlotId: Int): EuiccChannel?
 
-    /**
-     * Returns the first EuiccChannel corresponding to a **physical** slot
-     * If the physical slot supports MEP and has multiple ports, it is undefined
-     * which of the two channels will be returned.
-     */
-    fun findEuiccChannelByPhysicalSlotBlocking(physicalSlotId: Int): EuiccChannel?
-
-    /**
-     * Returns all EuiccChannels corresponding to a **physical** slot
-     * Multiple channels are possible in the case of MEP
-     */
-    suspend fun findAllEuiccChannelsByPhysicalSlot(physicalSlotId: Int): List<EuiccChannel>?
-    fun findAllEuiccChannelsByPhysicalSlotBlocking(physicalSlotId: Int): List<EuiccChannel>?
-
     /**
      * Returns the EuiccChannel corresponding to a **physical** slot and a port ID
      */

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

@@ -3,9 +3,6 @@ package im.angry.openeuicc.util
 import android.util.Log
 import im.angry.openeuicc.core.EuiccChannel
 import im.angry.openeuicc.core.EuiccChannelManager
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.withContext
 import net.typeblog.lpac_jni.LocalProfileAssistant
 import net.typeblog.lpac_jni.LocalProfileInfo
 
@@ -108,40 +105,4 @@ suspend inline fun EuiccChannelManager.beginTrackedOperation(
         }
     }
     Log.d(TAG, "Operation complete")
-}
-
-/**
- * Same as beginTrackedOperation but uses blocking primitives.
- * TODO: This function needs to be phased out of use.
- */
-inline fun EuiccChannelManager.beginTrackedOperationBlocking(
-    slotId: Int,
-    portId: Int,
-    op: () -> Boolean
-) {
-    val latestSeq =
-        findEuiccChannelByPortBlocking(slotId, portId)!!.lpa.notifications.firstOrNull()?.seqNumber
-            ?: 0
-    Log.d(TAG, "Latest notification is $latestSeq before operation")
-    if (op()) {
-        Log.d(TAG, "Operation has requested notification handling")
-        try {
-            // Note that the exact instance of "channel" might have changed here if reconnected;
-            // so we MUST use the automatic getter for "channel"
-            findEuiccChannelByPortBlocking(
-                slotId,
-                portId
-            )?.lpa?.notifications?.filter { it.seqNumber > latestSeq }?.forEach {
-                Log.d(TAG, "Handling notification $it")
-                findEuiccChannelByPortBlocking(
-                    slotId,
-                    portId
-                )?.lpa?.handleNotification(it.seqNumber)
-            }
-        } catch (e: Exception) {
-            // Ignore any error during notification handling
-            e.printStackTrace()
-        }
-    }
-    Log.d(TAG, "Operation complete")
 }