Meshtastic-Android/core/common/src
James Rich 092238cb55 refactor: use injected ioDispatcher and ApplicationCoroutineScope
Replaces two coroutine anti-patterns flagged by the architecture audit:

* FirmwareUpdateViewModel.onCleared() was using GlobalScope.launch to
  run cleanup work that must outlive the ViewModel scope. Introduce a
  new ApplicationCoroutineScope marker interface + Koin @Single binding
  in core/common, backed by SupervisorJob() + ioDispatcher, and inject
  it into the VM. NonCancellable is preserved so shutdown work still
  cannot be interrupted. Verified end-to-end by the KoinVerificationTest
  full-graph check.
* Six sites in feature/settings (android+jvm LogExporter/PrefExporter)
  and core/ui (android+jvm PlatformUtils) were hardcoding Dispatchers.IO.
  Switch to the project's injectable ioDispatcher property so tests
  can substitute a test dispatcher without reflection.

Dispatchers.Main sites in LogExporter are intentionally left alone —
they are fully test-swappable via Dispatchers.setMain() and there is
no existing mainDispatcher property to inject.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-17 10:53:08 -05:00
..
androidMain/kotlin/org/meshtastic/core/common chore: KMP audit — commonize code, centralize utilities, eliminate dead abstractions (#5133) 2026-04-15 02:17:50 +00:00
commonMain/kotlin/org/meshtastic/core/common refactor: use injected ioDispatcher and ApplicationCoroutineScope 2026-04-17 10:53:08 -05:00
commonTest/kotlin/org/meshtastic/core/common/util chore: KMP audit — commonize code, centralize utilities, eliminate dead abstractions (#5133) 2026-04-15 02:17:50 +00:00
iosMain/kotlin/org/meshtastic/core/common/util chore: KMP audit — commonize code, centralize utilities, eliminate dead abstractions (#5133) 2026-04-15 02:17:50 +00:00
jvmAndroidMain/kotlin/org/meshtastic/core/common/util chore: KMP audit — commonize code, centralize utilities, eliminate dead abstractions (#5133) 2026-04-15 02:17:50 +00:00
jvmMain/kotlin/org/meshtastic/core/common/util chore: KMP audit — commonize code, centralize utilities, eliminate dead abstractions (#5133) 2026-04-15 02:17:50 +00:00