瀏覽代碼

ui: Reduce blocking operations on transition

Peter Cai 1 年之前
父節點
當前提交
eab96dde05

+ 4 - 3
app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt

@@ -50,8 +50,9 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
     }
 
     override fun onInit() {
+        val logicalSlotId = intent.getIntExtra("logicalSlotId", 0)
         euiccChannel = euiccChannelManager
-            .findEuiccChannelBySlotBlocking(intent.getIntExtra("logicalSlotId", 0))!!
+            .findEuiccChannelBySlotBlocking(logicalSlotId)!!
 
         notificationList.layoutManager =
             LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
@@ -61,10 +62,10 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
 
         // 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)

+ 8 - 7
app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt

@@ -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)
             }
         }
     }