Skip to content

audio-studio/android: cover the foreground-service lifecycle with an instrumented test #478

Closed

Description

@abretonc7s

Follow-up from #477, suggested during its review.

ForegroundServiceLifecycleTest guards the #474 fix with source assertions: a truth table over the extracted rules, plus checks that each call site is wired to them. That was mutation-tested against 20+ regression shapes and catches every one, but it has a structural limit the reviewer named plainly:

Source parsing cannot prevent every future weakening [...] A behavior-level instrumented test would be the stronger follow-up.

The specific loophole left open, judged not worth blocking the merge: narrowing if (ownedService) with && recordingConfig.keepAwake passes the containment-based guard assertions and could leak a notification-only service.

What an instrumented test would assert

Run on a device, and check the service rather than the source:

  1. Record with the default config (keepAwake=true, showNotification=false), stop, assert no ServiceRecord remains
  2. Same with showNotification=true
  3. Record, stop, prepare a successor, assert no service is stranded
  4. Record with both flags false, assert no service was started

All four are exactly what was verified by hand on a Pixel 6a for #477 via dumpsys activity services. Automating them replaces source-shape assertions with behavioural ones.

Blocked by

#475 — the instrumentation harness cannot run at all today for sherpa-onnx.rn. Whether audio-studio's androidTest suite runs is worth checking separately before this is picked up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions