Compare commits
No commits in common. "41a53816f8a41197623d7a4edb6731ae53bd86b0" and "5eda8c63bb2bffd6747aa1cd2dbd49e4dd3c86bc" have entirely different histories.
41a53816f8
...
5eda8c63bb
5 changed files with 16 additions and 41 deletions
|
@ -29,6 +29,7 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import net.typeblog.lpac_jni.LocalProfileNotification
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesChangedListener {
|
open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesChangedListener {
|
||||||
|
@ -158,14 +159,6 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
||||||
preferenceRepository.notificationDisableFlow.first()
|
preferenceRepository.notificationDisableFlow.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun populatePopupWithProfileActions(popup: PopupMenu, profile: LocalProfileInfo) {
|
|
||||||
popup.inflate(R.menu.profile_options)
|
|
||||||
if (profile.isEnabled) {
|
|
||||||
popup.menu.findItem(R.id.enable).isVisible = false
|
|
||||||
popup.menu.findItem(R.id.delete).isVisible = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class ViewHolder(root: View) : RecyclerView.ViewHolder(root) {
|
sealed class ViewHolder(root: View) : RecyclerView.ViewHolder(root) {
|
||||||
enum class Type(val value: Int) {
|
enum class Type(val value: Int) {
|
||||||
PROFILE(0),
|
PROFILE(0),
|
||||||
|
@ -215,7 +208,7 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
||||||
name.text = profile.displayName
|
name.text = profile.displayName
|
||||||
|
|
||||||
state.setText(
|
state.setText(
|
||||||
if (profile.isEnabled) {
|
if (isEnabled()) {
|
||||||
R.string.enabled
|
R.string.enabled
|
||||||
} else {
|
} else {
|
||||||
R.string.disabled
|
R.string.disabled
|
||||||
|
@ -226,10 +219,19 @@ open class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfi
|
||||||
iccid.transformationMethod = PasswordTransformationMethod.getInstance()
|
iccid.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isEnabled(): Boolean =
|
||||||
|
profile.state == LocalProfileInfo.State.Enabled
|
||||||
|
|
||||||
private fun showOptionsMenu() {
|
private fun showOptionsMenu() {
|
||||||
PopupMenu(root.context, profileMenu).apply {
|
PopupMenu(root.context, profileMenu).apply {
|
||||||
setOnMenuItemClickListener(::onMenuItemClicked)
|
setOnMenuItemClickListener(::onMenuItemClicked)
|
||||||
populatePopupWithProfileActions(this, profile)
|
inflate(R.menu.profile_options)
|
||||||
|
if (isEnabled()) {
|
||||||
|
menu.findItem(R.id.enable).isVisible = false
|
||||||
|
menu.findItem(R.id.delete).isVisible = false
|
||||||
|
} else {
|
||||||
|
menu.findItem(R.id.disable).isVisible = false
|
||||||
|
}
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package im.angry.openeuicc.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import net.typeblog.lpac_jni.LocalProfileInfo
|
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
|
|
||||||
val Context.selfAppVersion: String
|
val Context.selfAppVersion: String
|
||||||
|
@ -12,7 +11,4 @@ val Context.selfAppVersion: String
|
||||||
pInfo.versionName
|
pInfo.versionName
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
throw RuntimeException(e)
|
throw RuntimeException(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
val LocalProfileInfo.isEnabled: Boolean
|
|
||||||
get() = state == LocalProfileInfo.State.Enabled
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/disable"
|
android:id="@+id/disable"
|
||||||
android:visible="false"
|
|
||||||
android:title="@string/disable"/>
|
android:title="@string/disable"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
|
|
@ -3,10 +3,8 @@ package im.angry.openeuicc.ui
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.PopupMenu
|
|
||||||
import im.angry.openeuicc.R
|
import im.angry.openeuicc.R
|
||||||
import im.angry.openeuicc.util.*
|
import im.angry.openeuicc.util.*
|
||||||
import net.typeblog.lpac_jni.LocalProfileInfo
|
|
||||||
|
|
||||||
class PrivilegedEuiccManagementFragment: EuiccManagementFragment() {
|
class PrivilegedEuiccManagementFragment: EuiccManagementFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -24,16 +22,4 @@ class PrivilegedEuiccManagementFragment: EuiccManagementFragment() {
|
||||||
} else {
|
} else {
|
||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun populatePopupWithProfileActions(popup: PopupMenu, profile: LocalProfileInfo) {
|
|
||||||
super.populatePopupWithProfileActions(popup, profile)
|
|
||||||
if (profile.isEnabled && !channel.removable) {
|
|
||||||
// Only show the disable option for non-removable eUICCs
|
|
||||||
// Some devices without internal eUICCs have the "optimization" of ignoring SIM
|
|
||||||
// slots without a valid profile. This can lead to "bricking" of external eUICCs
|
|
||||||
// at least for that specific device.
|
|
||||||
// TODO: Maybe we can still make this option available in some sort of "advanced" mode.
|
|
||||||
popup.menu.findItem(im.angry.openeuicc.common.R.id.disable).isVisible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -19,11 +19,9 @@ fun TelephonyManager.setDsdsEnabled(euiccManager: EuiccChannelManager, enabled:
|
||||||
euiccManager.enumerateEuiccChannels()
|
euiccManager.enumerateEuiccChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable all eSIM profiles before performing a DSDS switch (only for internal eSIMs)
|
// Disable all eSIM profiles before performing a DSDS switch
|
||||||
euiccManager.knownChannels.forEach {
|
euiccManager.knownChannels.forEach {
|
||||||
if (!it.removable) {
|
it.lpa.disableActiveProfileWithUndo()
|
||||||
it.lpa.disableActiveProfileWithUndo()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchMultiSimConfig(if (enabled) { 2 } else { 1 })
|
switchMultiSimConfig(if (enabled) { 2 } else { 1 })
|
||||||
|
@ -44,13 +42,7 @@ fun TelephonyManager.updateSimSlotMapping(
|
||||||
|
|
||||||
val undo = unmapped.mapNotNull { mapping ->
|
val undo = unmapped.mapNotNull { mapping ->
|
||||||
euiccManager.findEuiccChannelByPortBlocking(mapping.physicalSlotIndex, mapping.portIndex)?.let { channel ->
|
euiccManager.findEuiccChannelByPortBlocking(mapping.physicalSlotIndex, mapping.portIndex)?.let { channel ->
|
||||||
if (!channel.removable) {
|
return@mapNotNull channel.lpa.disableActiveProfileWithUndo()
|
||||||
return@mapNotNull channel.lpa.disableActiveProfileWithUndo()
|
|
||||||
} else {
|
|
||||||
// Do not do anything for external eUICCs -- we can't really trust them to work properly
|
|
||||||
// with no profile enabled.
|
|
||||||
return@mapNotNull null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue