ui: Allow disabling the only remaining profile through USB readers
All checks were successful
/ build-debug (push) Successful in 6m11s

This commit is contained in:
Peter Cai 2024-07-06 20:46:52 -04:00
parent b2fb3d23cb
commit 293266bb6e
2 changed files with 10 additions and 0 deletions

View file

@ -216,6 +216,13 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
if (profile.isEnabled) {
popup.menu.findItem(R.id.enable).isVisible = false
popup.menu.findItem(R.id.delete).isVisible = false
// We hide the disable option by default to avoid "bricking" some cards that won't get
// recognized again by the phone's modem. However we don't have that worry if we are
// accessing it through a USB card reader
if (isUsb) {
popup.menu.findItem(R.id.disable).isVisible = true
}
}
}

View file

@ -28,6 +28,9 @@ val <T> T.slotId: Int where T: Fragment, T: EuiccChannelFragmentMarker
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
val <T> T.euiccChannelManager: EuiccChannelManager where T: Fragment, T: EuiccChannelFragmentMarker
get() = (requireActivity() as BaseEuiccAccessActivity).euiccChannelManager
val <T> T.channel: EuiccChannel where T: Fragment, T: EuiccChannelFragmentMarker