|
@@ -3,6 +3,8 @@ package im.angry.openeuicc
|
|
|
import android.app.Application
|
|
import android.app.Application
|
|
|
import android.telephony.TelephonyManager
|
|
import android.telephony.TelephonyManager
|
|
|
import im.angry.openeuicc.core.EuiccChannelManager
|
|
import im.angry.openeuicc.core.EuiccChannelManager
|
|
|
|
|
+import im.angry.openeuicc.util.*
|
|
|
|
|
+import java.lang.Exception
|
|
|
|
|
|
|
|
class OpenEuiccApplication : Application() {
|
|
class OpenEuiccApplication : Application() {
|
|
|
val telephonyManager by lazy {
|
|
val telephonyManager by lazy {
|
|
@@ -12,4 +14,19 @@ class OpenEuiccApplication : Application() {
|
|
|
val euiccChannelManager by lazy {
|
|
val euiccChannelManager by lazy {
|
|
|
EuiccChannelManager(this)
|
|
EuiccChannelManager(this)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ override fun onCreate() {
|
|
|
|
|
+ super.onCreate()
|
|
|
|
|
+ // Clean up channels left open in TelephonyManager
|
|
|
|
|
+ // due to a (potentially) forced restart
|
|
|
|
|
+ for (slotId in 0 until EuiccChannelManager.MAX_SIMS) {
|
|
|
|
|
+ for (channel in 0 until 10) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ telephonyManager.iccCloseLogicalChannelBySlot(slotId, channel)
|
|
|
|
|
+ } catch (_: Exception) {
|
|
|
|
|
+ // We do not care
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|