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

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

fix: download a esim on multi-se (#282)

parent d40b8399
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -130,10 +130,8 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
            LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false)

        fab.setOnClickListener {
            Intent(requireContext(), DownloadWizardActivity::class.java).apply {
                putExtra("selectedLogicalSlot", logicalSlotId)
                startActivity(this)
            }
            val intent = DownloadWizardActivity.newIntent(requireContext(), slotId, seId)
            startActivity(intent)
        }
    }

+1 −3
Original line number Diff line number Diff line
@@ -258,9 +258,7 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
        val downloadShortcut = ShortcutInfoCompat.Builder(this, "download")
            .setShortLabel(getString(R.string.profile_download))
            .setIcon(IconCompat.createWithResource(this, R.drawable.ic_task_sim_card_download))
            .setIntent(Intent(this, DownloadWizardActivity::class.java).apply {
                action = Intent.ACTION_VIEW
            })
            .setIntent(DownloadWizardActivity.newIntent(this).apply { action = Intent.ACTION_VIEW })
            .build()
        return listOf(downloadShortcut)
    }
+20 −1
Original line number Diff line number Diff line
package im.angry.openeuicc.ui.wizard

import android.app.assist.AssistContent
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.WindowManager
@@ -17,6 +19,7 @@ import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import im.angry.openeuicc.common.R
import im.angry.openeuicc.core.EuiccChannel
import im.angry.openeuicc.core.EuiccChannelManager
import im.angry.openeuicc.ui.BaseEuiccAccessActivity
import im.angry.openeuicc.util.LPAString
@@ -26,6 +29,22 @@ import kotlinx.coroutines.launch
import net.typeblog.lpac_jni.LocalProfileAssistant

class DownloadWizardActivity : BaseEuiccAccessActivity() {
    companion object {
        const val TAG = "DownloadWizardActivity"

        private const val FIELD_LOGICAL_SLOT_ID = "selectedLogicalSlot"

        fun newIntent(
            context: Context,
            logicalSlotId: Int = 0,
            seId: EuiccChannel.SecureElementId = EuiccChannel.SecureElementId.DEFAULT
        ) = Intent(context, DownloadWizardActivity::class.java).apply {
            val selectedSyntheticSlotId = DownloadWizardSlotSelectFragment
                .encodeSyntheticSlotId(logicalSlotId, seId)
            putExtra(FIELD_LOGICAL_SLOT_ID, selectedSyntheticSlotId)
        }
    }

    data class DownloadWizardState(
        var currentStepFragmentClassName: String?,
        var selectedSyntheticSlotId: Int,
@@ -67,7 +86,7 @@ class DownloadWizardActivity : BaseEuiccAccessActivity() {

        state = DownloadWizardState(
            currentStepFragmentClassName = null,
            selectedSyntheticSlotId = intent.getIntExtra("selectedLogicalSlot", 0),
            selectedSyntheticSlotId = intent.getIntExtra(FIELD_LOGICAL_SLOT_ID, 0),
            smdp = "",
            matchingId = null,
            confirmationCode = null,
+4 −1
Original line number Diff line number Diff line
@@ -27,7 +27,10 @@ import kotlinx.coroutines.launch

class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardStepFragment() {
    companion object {
        fun decodeSyntheticSlotId(id: Int): Pair<Int, EuiccChannel.SecureElementId> =
        internal fun encodeSyntheticSlotId(logicalSlotId: Int, seId: EuiccChannel.SecureElementId): Int =
            (logicalSlotId shl 16) + seId.id

        internal fun decodeSyntheticSlotId(id: Int): Pair<Int, EuiccChannel.SecureElementId> =
            Pair(id shr 16, EuiccChannel.SecureElementId.createFromInt(id and 0xFF))
    }