|
@@ -85,19 +85,23 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun enableProfile(iccid: String) {
|
|
|
|
|
|
|
+ private fun enableOrDisableProfile(iccid: String, enable: Boolean) {
|
|
|
binding.swipeRefresh.isRefreshing = true
|
|
binding.swipeRefresh.isRefreshing = true
|
|
|
binding.swipeRefresh.isEnabled = false
|
|
binding.swipeRefresh.isEnabled = false
|
|
|
binding.fab.isEnabled = false
|
|
binding.fab.isEnabled = false
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
lifecycleScope.launch {
|
|
|
try {
|
|
try {
|
|
|
- doEnableProfile(iccid)
|
|
|
|
|
|
|
+ if (enable) {
|
|
|
|
|
+ doEnableProfile(iccid)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ doDisableProfile(iccid)
|
|
|
|
|
+ }
|
|
|
Toast.makeText(context, R.string.toast_profile_enabled, Toast.LENGTH_LONG).show()
|
|
Toast.makeText(context, R.string.toast_profile_enabled, Toast.LENGTH_LONG).show()
|
|
|
// The APDU channel will be invalid when the SIM reboots. For now, just exit the app
|
|
// The APDU channel will be invalid when the SIM reboots. For now, just exit the app
|
|
|
requireActivity().finish()
|
|
requireActivity().finish()
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
- Log.d(TAG, "Failed to enable profile $iccid")
|
|
|
|
|
|
|
+ Log.d(TAG, "Failed to enable / disable profile $iccid")
|
|
|
Log.d(TAG, Log.getStackTraceString(e))
|
|
Log.d(TAG, Log.getStackTraceString(e))
|
|
|
binding.fab.isEnabled = true
|
|
binding.fab.isEnabled = true
|
|
|
binding.swipeRefresh.isEnabled = true
|
|
binding.swipeRefresh.isEnabled = true
|
|
@@ -111,6 +115,11 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
|
|
|
channel.lpa.enableProfile(iccid, Progress())
|
|
channel.lpa.enableProfile(iccid, Progress())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private suspend fun doDisableProfile(iccid: String) =
|
|
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
|
|
+ channel.lpa.disableProfile(iccid, Progress())
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
inner class ViewHolder(private val binding: EuiccProfileBinding) : RecyclerView.ViewHolder(binding.root) {
|
|
inner class ViewHolder(private val binding: EuiccProfileBinding) : RecyclerView.ViewHolder(binding.root) {
|
|
|
init {
|
|
init {
|
|
|
binding.iccid.setOnClickListener {
|
|
binding.iccid.setOnClickListener {
|
|
@@ -159,6 +168,8 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
|
|
|
if (isEnabled()) {
|
|
if (isEnabled()) {
|
|
|
menu.findItem(R.id.enable).isVisible = false
|
|
menu.findItem(R.id.enable).isVisible = false
|
|
|
menu.findItem(R.id.delete).isVisible = false
|
|
menu.findItem(R.id.delete).isVisible = false
|
|
|
|
|
+ } else {
|
|
|
|
|
+ menu.findItem(R.id.disable).isVisible = false
|
|
|
}
|
|
}
|
|
|
show()
|
|
show()
|
|
|
}
|
|
}
|
|
@@ -167,7 +178,11 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
|
|
|
private fun onMenuItemClicked(item: MenuItem): Boolean =
|
|
private fun onMenuItemClicked(item: MenuItem): Boolean =
|
|
|
when (item.itemId) {
|
|
when (item.itemId) {
|
|
|
R.id.enable -> {
|
|
R.id.enable -> {
|
|
|
- enableProfile(profile[ICCID.name]!!)
|
|
|
|
|
|
|
+ enableOrDisableProfile(profile[ICCID.name]!!, true)
|
|
|
|
|
+ true
|
|
|
|
|
+ }
|
|
|
|
|
+ R.id.disable -> {
|
|
|
|
|
+ enableOrDisableProfile(profile[ICCID.name]!!, false)
|
|
|
true
|
|
true
|
|
|
}
|
|
}
|
|
|
R.id.rename -> {
|
|
R.id.rename -> {
|