DirectProfileDownloadActivity: Handle more potential cases
e.g. we can skip the slot selection dialog if there is only one chip in the device.
This commit is contained in:
parent
efeaea2567
commit
64c1fa93d3
|
@ -3,7 +3,7 @@ package im.angry.openeuicc.ui
|
|||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import im.angry.openeuicc.util.openEuiccApplication
|
||||
import im.angry.openeuicc.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -16,8 +16,21 @@ class DirectProfileDownloadActivity : AppCompatActivity(), SlotSelectFragment.Sl
|
|||
openEuiccApplication.euiccChannelManager.enumerateEuiccChannels()
|
||||
}
|
||||
|
||||
SlotSelectFragment.newInstance()
|
||||
.show(supportFragmentManager, SlotSelectFragment.TAG)
|
||||
val knownChannels = openEuiccApplication.euiccChannelManager.knownChannels
|
||||
when {
|
||||
knownChannels.isEmpty() -> {
|
||||
finish()
|
||||
}
|
||||
knownChannels.hasMultipleChips -> {
|
||||
SlotSelectFragment.newInstance()
|
||||
.show(supportFragmentManager, SlotSelectFragment.TAG)
|
||||
}
|
||||
else -> {
|
||||
// If the device has only one eSIM "chip" (but may be mapped to multiple slots),
|
||||
// we can skip the slot selection dialog since there is only one chip to save to.
|
||||
onSlotSelected(knownChannels[0].slotId, knownChannels[0].portId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package im.angry.openeuicc.util
|
|||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import im.angry.openeuicc.core.EuiccChannel
|
||||
import net.typeblog.lpac_jni.LocalProfileInfo
|
||||
import java.lang.RuntimeException
|
||||
|
||||
|
@ -15,4 +16,7 @@ val Context.selfAppVersion: String
|
|||
}
|
||||
|
||||
val LocalProfileInfo.isEnabled: Boolean
|
||||
get() = state == LocalProfileInfo.State.Enabled
|
||||
get() = state == LocalProfileInfo.State.Enabled
|
||||
|
||||
val List<EuiccChannel>.hasMultipleChips: Boolean
|
||||
get() = distinctBy { it.slotId }.size > 1
|
Loading…
Reference in a new issue