Compare commits

...

2 commits

Author SHA1 Message Date
16b6aceedf ui: Remove more blocking operations in NotificationsActivity
All checks were successful
/ build-debug (push) Successful in 5m4s
2024-10-12 11:09:16 -04:00
eab96dde05 ui: Reduce blocking operations on transition 2024-10-12 10:49:47 -04:00
2 changed files with 24 additions and 12 deletions

View file

@ -50,21 +50,20 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
}
override fun onInit() {
euiccChannel = euiccChannelManager
.findEuiccChannelBySlotBlocking(intent.getIntExtra("logicalSlotId", 0))!!
notificationList.layoutManager =
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
notificationList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
notificationList.adapter = notificationAdapter
registerForContextMenu(notificationList)
val logicalSlotId = intent.getIntExtra("logicalSlotId", 0)
// This is slightly different from the MainActivity logic
// due to the length (we don't want to display the full USB product name)
val channelTitle = if (euiccChannel.logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
val channelTitle = if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
getString(R.string.usb)
} else {
getString(R.string.channel_name_format, euiccChannel.logicalSlotId)
getString(R.string.channel_name_format, logicalSlotId)
}
title = getString(R.string.profile_notifications_detailed_format, channelTitle)
@ -105,6 +104,18 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
swipeRefresh.isRefreshing = true
lifecycleScope.launch {
if (!this@NotificationsActivity::euiccChannel.isInitialized) {
withContext(Dispatchers.IO) {
euiccChannelManagerLoaded.await()
euiccChannel = euiccChannelManager.findEuiccChannelBySlotBlocking(
intent.getIntExtra(
"logicalSlotId",
0
)
)!!
}
}
task()
swipeRefresh.isRefreshing = false

View file

@ -149,13 +149,6 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(),
@SuppressLint("MissingPermission")
override fun onStart() {
super.onStart()
profileDownloadIMEI.editText!!.text = Editable.Factory.getInstance().newEditable(
try {
telephonyManager.getImei(channel.logicalSlotId) ?: ""
} catch (e: Exception) {
""
}
)
lifecycleScope.launch(Dispatchers.IO) {
ensureEuiccChannelManager()
@ -166,6 +159,12 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(),
return@launch
}
val imei = try {
telephonyManager.getImei(channel.logicalSlotId) ?: ""
} catch (e: Exception) {
""
}
// Fetch remaining NVRAM
val str = channel.lpa.euiccInfo2?.freeNvram?.also {
freeNvram = it
@ -174,6 +173,8 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(),
withContext(Dispatchers.Main) {
profileDownloadFreeSpace.text = getString(R.string.profile_download_free_space,
str ?: getText(R.string.unknown))
profileDownloadIMEI.editText!!.text =
Editable.Factory.getInstance().newEditable(imei)
}
}
}