Skip to content

Extract monitoring orchestration from MonitorService#209

Merged
d4rken merged 1 commit intomainfrom
refactor/extract-monitor-orchestration
Apr 14, 2026
Merged

Extract monitoring orchestration from MonitorService#209
d4rken merged 1 commit intomainfrom
refactor/extract-monitor-orchestration

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented Apr 14, 2026

Summary

  • Extract VolumeEventDispatcher — moves volume event priority dispatch out of MonitorService into a standalone, testable class. Replaces Android SparseArray with groupBy/toSortedMap and fixes CancellationException swallowing.
  • Extract MonitorOrchestrator — moves flow wiring and shutdown heuristics out of MonitorService. Uses an internal child Job for lifecycle control instead of cancelling the caller's scope. Captures the initial device snapshot once to avoid a race condition.
  • Slim MonitorService down to a lifecycle shell (173 lines, 6 injections) — foreground promotion, session tracking, teardown, and notification updates via callback.

Test plan

  • VolumeEventDispatcherTest — 5 tests: priority ordering, parallel execution, error isolation, CancellationException rethrow, empty set
  • MonitorOrchestratorTest — 9 tests: bootstrap sequence, 3 shutdown heuristic branches, device list updates, 3 failure isolation lanes
  • assembleFossDebug compiles
  • Manual: connect/disconnect Bluetooth device, verify volume adjustment and service shutdown unchanged

@d4rken d4rken merged commit 8e8ab2d into main Apr 14, 2026
10 checks passed
@d4rken d4rken deleted the refactor/extract-monitor-orchestration branch April 14, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant