WIP: feat: filter with enabled profile class #112

Closed
septs wants to merge 4 commits from septs:filter-with-enabled into master
4 changed files with 18 additions and 25 deletions

View file

@ -460,10 +460,7 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
R.drawable.ic_task_switch
) {
euiccChannelManager.beginTrackedOperation(slotId, portId) {
val (res, refreshed) = euiccChannelManager.withEuiccChannel(
slotId,
portId
) { channel ->
val (res, refreshed) = euiccChannelManager.withEuiccChannel(slotId, portId) { channel ->
if (!channel.lpa.switchProfile(iccid, enable, refresh = true)) {
// Sometimes, we *can* enable or disable the profile, but we cannot
// send the refresh command to the modem because the profile somehow

View file

@ -194,8 +194,11 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
euiccChannelManager.notifyEuiccProfilesChanged(channel.logicalSlotId)
if (unfilteredProfileListFlow.value)
channel.lpa.profiles
else
channel.lpa.profiles.operational
else {
val clazz = channel.lpa.profiles.enabled?.profileClass
?: LocalProfileInfo.Clazz.Operational
channel.lpa.profiles.filter { it.profileClass == clazz }
}
}
withContext(Dispatchers.Main) {
@ -227,11 +230,7 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
portId,
iccid,
enable,
reconnectTimeoutMillis = if (isUsb) {
0
} else {
30 * 1000
}
reconnectTimeoutMillis = if (isUsb) 0 else 30_000
).waitDone()
when (err) {

View file

@ -11,14 +11,11 @@ const val TAG = "LPAUtils"
val LocalProfileInfo.displayName: String
get() = nickName.ifEmpty { name }
val LocalProfileInfo.isEnabled: Boolean
get() = state == LocalProfileInfo.State.Enabled
val List<LocalProfileInfo>.operational: List<LocalProfileInfo>
get() = filter {
it.profileClass == LocalProfileInfo.Clazz.Operational
}
val List<LocalProfileInfo>.enabled: LocalProfileInfo?
get() = firstOrNull { it.isEnabled }
val List<EuiccChannel>.hasMultipleChips: Boolean
get() = distinctBy { it.slotId }.size > 1

View file

@ -186,16 +186,16 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
)
}
try {
return@withEuiccChannelManager euiccChannelManager.withEuiccChannel(
slotId,
port
) { channel ->
return@withEuiccChannelManager try {
euiccChannelManager.withEuiccChannel(slotId, port) { channel ->
val filteredProfiles =
if (runBlocking { preferenceRepository.unfilteredProfileListFlow.first() })
if (preferenceRepository.unfilteredProfileListFlow.first())
channel.lpa.profiles
else
channel.lpa.profiles.operational
else {
val clazz = channel.lpa.profiles.enabled?.profileClass
?: LocalProfileInfo.Clazz.Operational
channel.lpa.profiles.filter { it.profileClass == clazz }
}
val profiles = filteredProfiles.map {
EuiccProfileInfo.Builder(it.iccid).apply {
setProfileName(it.name)
@ -224,7 +224,7 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
)
}
} catch (e: EuiccChannelManager.EuiccChannelNotFoundException) {
return@withEuiccChannelManager GetEuiccProfileInfoListResult(
GetEuiccProfileInfoListResult(
RESULT_FIRST_USER,
arrayOf(),
true