Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17102be7 authored by septs's avatar septs Committed by Peter Cai
Browse files

feat: Allow forcing the use of TelephonyManager everywhere

Manual merge of #139, but removed all reference to "TMAPI" because such
a term does not exist.

Also reworked PreferenceRepository to allow extensibility from the
privileged app.
parent ece231f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ open class SettingsFragment: PreferenceFragmentCompat() {
        return true
    }

    private fun CheckBoxPreference.bindBooleanFlow(flow: PreferenceFlowWrapper<Boolean>) {
    protected fun CheckBoxPreference.bindBooleanFlow(flow: PreferenceFlowWrapper<Boolean>) {
        lifecycleScope.launch {
            flow.collect { isChecked = it }
        }
+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ internal object PreferenceKeys {
    val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate")
}

class PreferenceRepository(private val context: Context) {
open class PreferenceRepository(private val context: Context) {
    // Expose flows so that we can also handle default values
    // ---- Profile Notifications ----
    val notificationDownloadFlow = bindFlow(PreferenceKeys.NOTIFICATION_DOWNLOAD, true)
@@ -51,7 +51,7 @@ class PreferenceRepository(private val context: Context) {
    val unfilteredProfileListFlow = bindFlow(PreferenceKeys.UNFILTERED_PROFILE_LIST, false)
    val ignoreTLSCertificateFlow = bindFlow(PreferenceKeys.IGNORE_TLS_CERTIFICATE, false)

    private fun <T> bindFlow(key: Preferences.Key<T>, defaultValue: T): PreferenceFlowWrapper<T> =
    protected fun <T> bindFlow(key: Preferences.Key<T>, defaultValue: T): PreferenceFlowWrapper<T> =
        PreferenceFlowWrapper(context, key, defaultValue)
}

+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@

    </PreferenceCategory>

    <PreferenceCategory
    <im.angry.openeuicc.ui.preference.LongSummaryPreferenceCategory
        app:key="pref_developer"
        app:title="@string/pref_developer"
        app:iconSpaceReserved="false">
@@ -69,7 +69,7 @@
            app:summary="@string/pref_developer_ignore_tls_certificate_desc"
            app:title="@string/pref_developer_ignore_tls_certificate" />

    </PreferenceCategory>
    </im.angry.openeuicc.ui.preference.LongSummaryPreferenceCategory>

    <PreferenceCategory
        app:key="pref_info"
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.util.Log
import im.angry.openeuicc.OpenEuiccApplication
import im.angry.openeuicc.R
import im.angry.openeuicc.util.*
import kotlinx.coroutines.flow.first
import java.lang.IllegalArgumentException

class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFactory(context) {
@@ -21,7 +22,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
            super.tryOpenEuiccChannel(port)?.let { return it }
        }

        if (port.card.isEuicc) {
        if (port.card.isEuicc || (context.preferenceRepository as PrivilegedPreferenceRepository).removableTelephonyManagerFlow.first()) {
            Log.i(
                DefaultEuiccChannelManager.TAG,
                "Trying TelephonyManager for slot ${port.card.physicalSlotIndex} port ${port.portIndex}"
+5 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import im.angry.openeuicc.core.EuiccChannelManagerFactory
import im.angry.openeuicc.core.PrivilegedEuiccChannelFactory
import im.angry.openeuicc.core.PrivilegedEuiccChannelManager
import im.angry.openeuicc.core.PrivilegedEuiccChannelManagerFactory
import im.angry.openeuicc.util.*

class PrivilegedAppContainer(context: Context) : DefaultAppContainer(context) {
    override val euiccChannelManager: EuiccChannelManager by lazy {
@@ -27,4 +28,8 @@ class PrivilegedAppContainer(context: Context) : DefaultAppContainer(context) {
    override val customizableTextProvider by lazy {
        PrivilegedCustomizableTextProvider(context)
    }

    override val preferenceRepository by lazy {
        PrivilegedPreferenceRepository(context)
    }
}
 No newline at end of file
Loading