Compare commits

..

No commits in common. "3013609ff5a0cbae895dcb1ce843a376a81c8d67" and "eb862301cc64ff9530997cb656698f7f33d456e0" have entirely different histories.

6 changed files with 8 additions and 40 deletions

View file

@ -1,7 +1,6 @@
package im.angry.openeuicc
import android.app.Application
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import im.angry.openeuicc.core.EuiccChannelManager
import im.angry.openeuicc.util.*
@ -16,10 +15,6 @@ class OpenEuiccApplication : Application() {
EuiccChannelManager(this)
}
val subscriptionManager by lazy {
getSystemService(SubscriptionManager::class.java)!!
}
override fun onCreate() {
super.onCreate()
// Clean up channels left open in TelephonyManager

View file

@ -9,7 +9,6 @@ interface EuiccChannelStateManager {
data class EuiccChannel(
val slotId: Int,
val cardId: Int,
val name: String,
val lpa: LocalProfileAssistant,
val stateManager: EuiccChannelStateManager

View file

@ -56,10 +56,10 @@ class EuiccChannelManager(private val context: Context) {
}
}
val (shouldTryTelephonyManager, cardId) =
val shouldTryTelephonyManager =
tm.uiccCardsInfo.find { it.slotIndex == slotId }?.let {
Pair(it.isEuicc && !it.isRemovable, it.cardId)
} ?: Pair(false, 0)
it.isEuicc && !it.isRemovable
} ?: false
var apduChannel: ApduChannel? = null
var stateManager: EuiccChannelStateManager? = null
@ -81,11 +81,7 @@ class EuiccChannelManager(private val context: Context) {
} ?: return null
}
val channel = EuiccChannel(
slotId, cardId,
"SIM $slotId",
LocalProfileAssistantImpl(apduChannel),
stateManager!!)
val channel = EuiccChannel(slotId, "SIM $slotId", LocalProfileAssistantImpl(apduChannel), stateManager!!)
channels.add(channel)
return channel
}

View file

@ -19,8 +19,6 @@ import com.truphone.lpad.progress.Progress
import im.angry.openeuicc.R
import im.angry.openeuicc.databinding.EuiccProfileBinding
import im.angry.openeuicc.databinding.FragmentEuiccBinding
import im.angry.openeuicc.util.openEuiccApplication
import im.angry.openeuicc.util.tryRefreshCachedEuiccInfo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -76,7 +74,6 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
lifecycleScope.launch {
val profiles = withContext(Dispatchers.IO) {
openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(channel.cardId)
channel.lpa.profiles
}

View file

@ -15,7 +15,9 @@ import androidx.lifecycle.lifecycleScope
import im.angry.openeuicc.R
import im.angry.openeuicc.core.EuiccChannelManager
import im.angry.openeuicc.databinding.ActivityMainBinding
import im.angry.openeuicc.util.*
import im.angry.openeuicc.util.dsdsEnabled
import im.angry.openeuicc.util.openEuiccApplication
import im.angry.openeuicc.util.supportsDSDS
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -97,7 +99,6 @@ class MainActivity : AppCompatActivity() {
manager.knownChannels.forEach {
Log.d(TAG, it.name)
Log.d(TAG, it.lpa.eid)
openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(it.cardId)
}
}

View file

@ -1,9 +1,7 @@
package im.angry.openeuicc.util
import android.telephony.IccOpenLogicalChannelResponse
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import java.lang.Exception
import java.lang.reflect.Method
val TelephonyManager.supportsDSDS: Boolean
@ -15,16 +13,6 @@ var TelephonyManager.dsdsEnabled: Boolean
switchMultiSimConfig(if (value) { 2 } else {1})
}
fun SubscriptionManager.tryRefreshCachedEuiccInfo(cardId: Int) {
if (cardId != 0) {
try {
requestEmbeddedSubscriptionInfoListRefresh(cardId)
} catch (e: Exception) {
// Ignore
}
}
}
// Hidden APIs via reflection to enable building without AOSP source tree
private val iccOpenLogicalChannelBySlot: Method by lazy {
TelephonyManager::class.java.getMethod(
@ -60,12 +48,4 @@ fun TelephonyManager.iccTransmitApduLogicalChannelBySlot(
): String? =
iccTransmitApduLogicalChannelBySlot.invoke(
this, slotId, channel, cla, instruction, p1, p2, p3, data
) as String?
private val requestEmbeddedSubscriptionInfoListRefresh: Method by lazy {
SubscriptionManager::class.java.getMethod("requestEmbeddedSubscriptionInfoListRefresh", Int::class.java)
}
fun SubscriptionManager.requestEmbeddedSubscriptionInfoListRefresh(cardId: Int): Unit {
requestEmbeddedSubscriptionInfoListRefresh.invoke(this, cardId)
}
) as String?