Compare commits
No commits in common. "ed585edf49cb57d131e43c4a61297ce3b4180609" and "e708deea7caa621d0d5390e435a82bca196e4305" have entirely different histories.
ed585edf49
...
e708deea7c
11 changed files with 26 additions and 157 deletions
|
@ -10,8 +10,8 @@ abstract class EuiccChannel(
|
|||
val logicalSlotId = port.logicalSlotIndex
|
||||
val portId = port.portIndex
|
||||
val cardId = port.card.cardId
|
||||
val name = "SLOT $logicalSlotId"
|
||||
val removable = port.card.isRemovable
|
||||
val isMEP = port.card.isMultipleEnabledProfilesSupported
|
||||
|
||||
abstract val lpa: LocalProfileAssistant
|
||||
val valid: Boolean
|
||||
|
|
|
@ -161,7 +161,7 @@ open class EuiccChannelManager(protected val context: Context) {
|
|||
seService = null
|
||||
}
|
||||
|
||||
open fun notifyEuiccProfilesChanged(logicalSlotId: Int) {
|
||||
open fun notifyEuiccProfilesChanged(slotId: Int) {
|
||||
// No-op for unprivileged
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import android.view.LayoutInflater
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.TextView
|
||||
|
@ -27,7 +26,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import java.lang.Exception
|
||||
|
||||
open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesChangedListener {
|
||||
class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesChangedListener {
|
||||
companion object {
|
||||
const val TAG = "EuiccManagementFragment"
|
||||
|
||||
|
@ -39,7 +38,7 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
|||
private lateinit var fab: FloatingActionButton
|
||||
private lateinit var profileList: RecyclerView
|
||||
|
||||
private val adapter = EuiccProfileAdapter()
|
||||
private val adapter = EuiccProfileAdapter(listOf())
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -77,21 +76,18 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
|||
refresh()
|
||||
}
|
||||
|
||||
protected open suspend fun onCreateFooterViews(parent: ViewGroup): List<View> = listOf()
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun refresh() {
|
||||
swipeRefresh.isRefreshing = true
|
||||
|
||||
lifecycleScope.launch {
|
||||
val profiles = withContext(Dispatchers.IO) {
|
||||
euiccChannelManager.notifyEuiccProfilesChanged(channel.logicalSlotId)
|
||||
euiccChannelManager.notifyEuiccProfilesChanged(slotId)
|
||||
channel.lpa.profiles
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
adapter.profiles = profiles.operational
|
||||
adapter.footerViews = onCreateFooterViews(profileList)
|
||||
adapter.notifyDataSetChanged()
|
||||
swipeRefresh.isRefreshing = false
|
||||
}
|
||||
|
@ -134,30 +130,7 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
|||
channel.lpa.disableProfile(iccid)
|
||||
}
|
||||
|
||||
sealed class ViewHolder(root: View) : RecyclerView.ViewHolder(root) {
|
||||
enum class Type(val value: Int) {
|
||||
PROFILE(0),
|
||||
FOOTER(1);
|
||||
|
||||
companion object {
|
||||
fun fromInt(value: Int) =
|
||||
Type.values().first { it.value == value }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inner class FooterViewHolder: ViewHolder(FrameLayout(requireContext())) {
|
||||
fun attach(view: View) {
|
||||
view.parent?.let { (it as ViewGroup).removeView(view) }
|
||||
(itemView as FrameLayout).addView(view)
|
||||
}
|
||||
|
||||
fun detach() {
|
||||
(itemView as FrameLayout).removeAllViews()
|
||||
}
|
||||
}
|
||||
|
||||
inner class ProfileViewHolder(private val root: View) : ViewHolder(root) {
|
||||
inner class ViewHolder(private val root: View) : RecyclerView.ViewHolder(root) {
|
||||
private val iccid: TextView = root.findViewById(R.id.iccid)
|
||||
private val name: TextView = root.findViewById(R.id.name)
|
||||
private val state: TextView = root.findViewById(R.id.state)
|
||||
|
@ -235,49 +208,16 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
|||
}
|
||||
}
|
||||
|
||||
inner class EuiccProfileAdapter : RecyclerView.Adapter<ViewHolder>() {
|
||||
var profiles: List<LocalProfileInfo> = listOf()
|
||||
var footerViews: List<View> = listOf()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
|
||||
when (ViewHolder.Type.fromInt(viewType)) {
|
||||
ViewHolder.Type.PROFILE -> {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.euicc_profile, parent, false)
|
||||
ProfileViewHolder(view)
|
||||
}
|
||||
ViewHolder.Type.FOOTER -> {
|
||||
FooterViewHolder()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int =
|
||||
when {
|
||||
position < profiles.size -> {
|
||||
ViewHolder.Type.PROFILE.value
|
||||
}
|
||||
position >= profiles.size && position < profiles.size + footerViews.size -> {
|
||||
ViewHolder.Type.FOOTER.value
|
||||
}
|
||||
else -> -1
|
||||
}
|
||||
inner class EuiccProfileAdapter(var profiles: List<LocalProfileInfo>) : RecyclerView.Adapter<ViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.euicc_profile, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is ProfileViewHolder -> {
|
||||
holder.setProfile(profiles[position])
|
||||
}
|
||||
is FooterViewHolder -> {
|
||||
holder.attach(footerViews[position - profiles.size])
|
||||
}
|
||||
}
|
||||
holder.setProfile(profiles[position])
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
if (holder is FooterViewHolder) {
|
||||
holder.detach()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = profiles.size + footerViews.size
|
||||
override fun getItemCount(): Int = profiles.size
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import android.widget.Spinner
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
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.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -73,26 +72,23 @@ open class MainActivity : AppCompatActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
protected open fun createEuiccManagementFragment(channel: EuiccChannel): EuiccManagementFragment =
|
||||
EuiccManagementFragment.newInstance(channel.slotId, channel.portId)
|
||||
|
||||
private suspend fun init() {
|
||||
withContext(Dispatchers.IO) {
|
||||
manager.enumerateEuiccChannels()
|
||||
manager.knownChannels.forEach {
|
||||
Log.d(TAG, "slot ${it.slotId} port ${it.portId}")
|
||||
Log.d(TAG, it.name)
|
||||
Log.d(TAG, it.lpa.eID)
|
||||
// Request the system to refresh the list of profiles every time we start
|
||||
// Note that this is currently supposed to be no-op when unprivileged,
|
||||
// but it could change in the future
|
||||
manager.notifyEuiccProfilesChanged(it.logicalSlotId)
|
||||
manager.notifyEuiccProfilesChanged(it.slotId)
|
||||
}
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
manager.knownChannels.sortedBy { it.logicalSlotId }.forEach { channel ->
|
||||
spinnerAdapter.add(getString(R.string.channel_name_format, channel.logicalSlotId))
|
||||
fragments.add(createEuiccManagementFragment(channel))
|
||||
manager.knownChannels.forEach { channel ->
|
||||
spinnerAdapter.add(channel.name)
|
||||
fragments.add(EuiccManagementFragment.newInstance(channel.slotId, channel.portId))
|
||||
}
|
||||
|
||||
if (fragments.isNotEmpty()) {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
<string name="no_euicc">No eUICC card on this device is accessible by this app.\nInsert a supported eUICC card, or try out the privileged OpenEUICC app instead.</string>
|
||||
<string name="unknown">Unknown</string>
|
||||
|
||||
<string name="channel_name_format">Logical Slot %d</string>
|
||||
|
||||
<string name="enabled">Enabled</string>
|
||||
<string name="disabled">Disabled</string>
|
||||
<string name="provider">Provider:</string>
|
||||
|
|
|
@ -45,9 +45,9 @@ class PrivilegedEuiccChannelManager(context: Context): EuiccChannelManager(conte
|
|||
}
|
||||
}
|
||||
|
||||
override fun notifyEuiccProfilesChanged(logicalSlotId: Int) {
|
||||
override fun notifyEuiccProfilesChanged(slotId: Int) {
|
||||
(context.applicationContext as OpenEuiccApplication).subscriptionManager.apply {
|
||||
findEuiccChannelBySlotBlocking(logicalSlotId)?.let {
|
||||
findEuiccChannelBySlotBlocking(slotId)?.let {
|
||||
tryRefreshCachedEuiccInfo(it.cardId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package im.angry.openeuicc.ui
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import im.angry.openeuicc.R
|
||||
|
||||
class PrivilegedEuiccManagementFragment: EuiccManagementFragment() {
|
||||
companion object {
|
||||
fun newInstance(slotId: Int, portId: Int): EuiccManagementFragment =
|
||||
newInstanceEuicc(PrivilegedEuiccManagementFragment::class.java, slotId, portId)
|
||||
}
|
||||
|
||||
override suspend fun onCreateFooterViews(parent: ViewGroup): List<View> =
|
||||
if (channel.isMEP) {
|
||||
val view = layoutInflater.inflate(R.layout.footer_mep, parent, false)
|
||||
view.findViewById<Button>(R.id.footer_mep_slot_mapping).setOnClickListener {
|
||||
(requireActivity() as PrivilegedMainActivity).showSlotMappingFragment()
|
||||
}
|
||||
listOf(view)
|
||||
} else {
|
||||
listOf()
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import im.angry.openeuicc.R
|
||||
import im.angry.openeuicc.core.EuiccChannel
|
||||
import im.angry.openeuicc.util.*
|
||||
|
||||
class PrivilegedMainActivity : MainActivity() {
|
||||
|
@ -21,9 +20,6 @@ class PrivilegedMainActivity : MainActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
internal fun showSlotMappingFragment() =
|
||||
SlotMappingFragment().show(supportFragmentManager, SlotMappingFragment.TAG)
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
||||
R.id.dsds -> {
|
||||
tm.dsdsEnabled = !item.isChecked
|
||||
|
@ -32,12 +28,9 @@ class PrivilegedMainActivity : MainActivity() {
|
|||
true
|
||||
}
|
||||
R.id.slot_mapping -> {
|
||||
showSlotMappingFragment()
|
||||
SlotMappingFragment().show(supportFragmentManager, SlotMappingFragment.TAG)
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun createEuiccManagementFragment(channel: EuiccChannel): EuiccManagementFragment =
|
||||
PrivilegedEuiccManagementFragment.newInstance(channel.slotId, channel.portId)
|
||||
}
|
|
@ -111,11 +111,11 @@ class SlotMappingFragment: DialogFragment(), OnMenuItemClickListener {
|
|||
}
|
||||
|
||||
private suspend fun buildHelpText() = withContext(Dispatchers.IO) {
|
||||
val nLogicalSlots = adapter.mappings.size
|
||||
var nLogicalSlots = adapter.mappings.size
|
||||
|
||||
val cards = openEuiccApplication.telephonyManager.uiccCardsInfoCompat
|
||||
|
||||
val nPhysicalSlots = cards.size
|
||||
var nPhysicalSlots = cards.size
|
||||
var idxMepCard = -1
|
||||
var nMepPorts = 0
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/footer_mep_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/footer_mep"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/footer_mep_slot_mapping"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/footer_mep_slot_mapping"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/slot_mapping"
|
||||
android:textColor="?attr/colorAccent"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
app:layout_constraintTop_toBottomOf="@id/footer_mep_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -6,14 +6,12 @@
|
|||
|
||||
<string name="toast_dsds_switched">DSDS state switched. Please wait until the modem restarts.</string>
|
||||
|
||||
<string name="footer_mep">Multiple Enabled Profiles (MEP) is supported by this slot. To enable or disable this feature, use the \"Slot Mapping\" tool.</string>
|
||||
|
||||
<string name="slot_mapping">Slot Mapping</string>
|
||||
<string name="slot_mapping_logical_slot">Logical slot %d:</string>
|
||||
<string name="slot_mapping_port">Slot %d Port %d</string>
|
||||
<string name="slot_mapping_help">Your phone has %d logical and %d physical SIM slots.%s\n\nSelect which physical slot and/or \"port\" you want each logical slot to correspond to. Note that not all mapping modes may be supported by hardware.</string>
|
||||
<string name="slot_mapping_help_mep">\n\nPhysical slot %d supports Multiple Enabled Profiles (MEP). To use this feature, assign its %d virtual \"ports\" to different logical slots shown above.\n\nWith MEP enabled, the \"ports\" will behave like separate eSIM slots in OpenEUICC, except with a shared profile list.</string>
|
||||
<string name="slot_mapping_help_dsds">\nDual SIM mode is supported but disabled. If your device comes with an internal eSIM chip, it might not be enabled by default. Change mapping above or enable dual SIM to access your eSIM.</string>
|
||||
<string name="slot_mapping_help">Your phone has %d logical and %d physical SIM slots.%s\n\nSelect which physical slot and/or "port" you want each logical slot to correspond to. Note that not all mapping modes may be supported by hardware.</string>
|
||||
<string name="slot_mapping_help_mep">\n\nPhysical slot %d supports Multiple Enabled Profiles (MEP). To use this feature, associate its %d virtual "ports" to different logical slots shown above.</string>
|
||||
<string name="slot_mapping_help_dsds">\nDual SIM mode is supported but disabled.</string>
|
||||
<string name="slot_mapping_completed">Your new slot mapping has been set. Please wait until modem refreshes the slots.</string>
|
||||
<string name="slot_mapping_failure">The specified mapping might be invalid or unsupported by hardware.</string>
|
||||
</resources>
|
Loading…
Add table
Reference in a new issue