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

Commit f498c22a authored by Peter Cai's avatar Peter Cai
Browse files

refactor: Pass multi-SE metadata inside EuiccChannel so it can be shown in MainActivity

parent c23ad214
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -109,6 +109,10 @@ open class DefaultEuiccChannelManager(
            break
        }

        // Set the hasMultipleSE field now since we only get to know that after we have iterated all AIDs
        // This also flips a flag in EuiccChannelImpl and prevents the field from being set again
        ret.forEach { it.hasMultipleSE = (seId > 1) }

        return ret
    }

+8 −0
Original line number Diff line number Diff line
@@ -68,6 +68,14 @@ interface EuiccChannel {
     */
    val seId: SecureElementId

    /**
     * Does this channel belong to a chip that supports multiple SEs?
     * Note that this is only made `var` to make initialization a bit less annoying --
     * this should never be set again after the channel is originally opened.
     * Attempting to do so will yield an exception.
     */
    var hasMultipleSE: Boolean

    val lpa: LocalProfileAssistant

    val valid: Boolean
+11 −0
Original line number Diff line number Diff line
@@ -39,5 +39,16 @@ class EuiccChannelImpl(
    override val valid: Boolean
        get() = lpa.valid

    private var hasMultipleSEInitialized = false

    override var hasMultipleSE: Boolean = false
        set(value) {
            if (hasMultipleSEInitialized) {
                throw IllegalStateException("already initialized")
            }

            field = value
        }

    override fun close() = lpa.close()
}
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ class EuiccChannelWrapper(orig: EuiccChannel) : EuiccChannel {
        get() = channel.atr
    override val isdrAid: ByteArray
        get() = channel.isdrAid
    override var hasMultipleSE: Boolean
        get() = channel.hasMultipleSE
        set(value) {
            channel.hasMultipleSE = value
        }

    override fun close() = channel.close()

+7 −1
Original line number Diff line number Diff line
@@ -166,8 +166,14 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
                    // but it could change in the future
                    euiccChannelManager.notifyEuiccProfilesChanged(channel.logicalSlotId)

                    val channelName =
                    val channelName = if (channel.hasMultipleSE) {
                        appContainer.customizableTextProvider.formatNonUsbChannelNameWithSeId(
                            channel.logicalSlotId,
                            channel.seId
                        )
                    } else {
                        appContainer.customizableTextProvider.formatNonUsbChannelName(channel.logicalSlotId)
                    }
                    newPages.add(Page(channel.logicalSlotId, channelName) {
                        appContainer.uiComponentFactory.createEuiccManagementFragment(
                            slotId,
Loading