fix: Do not look for channel in the process of switching profiles
All checks were successful
/ build-debug (push) Successful in 5m13s

Fixes #36
This commit is contained in:
Peter Cai 2024-07-12 17:17:32 -04:00
parent 829f019aa2
commit 67927cf7ef
2 changed files with 5 additions and 3 deletions

View file

@ -180,7 +180,7 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
return@beginTrackedOperation false
}
if (!refreshed && channel.slotId != EuiccChannelManager.USB_CHANNEL_ID) {
if (!refreshed && !isUsb) {
withContext(Dispatchers.Main) {
AlertDialog.Builder(requireContext()).apply {
setMessage(R.string.switch_did_not_refresh)
@ -197,7 +197,7 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
return@beginTrackedOperation true
}
if (channel.slotId != EuiccChannelManager.USB_CHANNEL_ID) {
if (!isUsb) {
try {
euiccChannelManager.waitForReconnect(
slotId,

View file

@ -23,11 +23,13 @@ fun <T> newInstanceEuicc(clazz: Class<T>, slotId: Int, portId: Int, addArguments
return instance
}
// Convenient methods to avoid using `channel` for these
// `channel` requires that the channel actually exists in EuiccChannelManager, which is
// not always the case during operations such as switching
val <T> T.slotId: Int where T: Fragment, T: EuiccChannelFragmentMarker
get() = requireArguments().getInt("slotId")
val <T> T.portId: Int where T: Fragment, T: EuiccChannelFragmentMarker
get() = requireArguments().getInt("portId")
val <T> T.isUsb: Boolean where T: Fragment, T: EuiccChannelFragmentMarker
get() = requireArguments().getInt("slotId") == EuiccChannelManager.USB_CHANNEL_ID