Browse Source

Enforce updateForegroundNotification to run in the main thread

Peter Cai 1 year ago
parent
commit
9a77824f79

+ 3 - 1
app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt

@@ -178,7 +178,9 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
         // until we encounter ForegroundTaskState.Done.
         // until we encounter ForegroundTaskState.Done.
         return foregroundTaskState.transformWhile {
         return foregroundTaskState.transformWhile {
             // Also update our notification when we see an update
             // Also update our notification when we see an update
-            updateForegroundNotification(title, iconRes)
+            withContext(Dispatchers.Main) {
+                updateForegroundNotification(title, iconRes)
+            }
             emit(it)
             emit(it)
             it !is ForegroundTaskState.Done
             it !is ForegroundTaskState.Done
         }.onCompletion { foregroundTaskState.value = ForegroundTaskState.Idle }
         }.onCompletion { foregroundTaskState.value = ForegroundTaskState.Idle }