Skip to content

fix(player): stop lockscreen media tile from showing a duplicate Play button - #511

Merged
github-actions[bot] merged 1 commit into
devfrom
fix/lockscreen-duplicate-play-button
Aug 24, 2026
Merged

github-actions[bot] merged 1 commit into
devfrom
fix/lockscreen-duplicate-play-button

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

Summary

On Android, the lockscreen / status-bar media notification control row showed a duplicate Play button and dropped/misplaced the "skip to next" button.

LibravaultMediaCallback.onConnect publishes a 5-button customLayout ([Prev | −seek | PlayPause | +seek | Next]) and strips the overlapping standard seek/skip commands from availablePlayerCommands so the system doesn't also derive standard-action buttons for the same controls. Player.COMMAND_PLAY_PAUSE was deliberately left in, on the assumption that the system tile's central glyph is driven by PlaybackStateCompat.state alone, not a separate action slot.

That assumption doesn't hold on every device/Android version — the system additionally derives a standalone play/pause action bit from COMMAND_PLAY_PAUSE being present, producing a duplicate Play button and pushing "Next" out of the five-slot row.

Fix

Remove Player.COMMAND_PLAY_PAUSE from availablePlayerCommands in LibravaultMediaCallback.onConnect — same treatment already given to the overlapping seek/skip commands. The custom-layout's own Play/Pause button (slot 3) still drives the central glyph via PlaybackStateCompat.state, which is set independently of this command.

Testing

  • Added LibravaultMediaCallbackConnectTest (Robolectric — onConnect reads the real android.os.Bundle.EMPTY static field, which is null under this module's plain-JVM isReturnDefaultValues stub, so a plain-JUnit5 test NPEs before reaching the assertion). Confirmed red on the pre-fix code, green after the fix.
  • ./gradlew :feature:player:testDebugUnitTest passes locally.

Verification caveat

This is presentation-layer behavior driven by the OS's own MediaStyle notification rendering (as the issue itself calls out) — not something a JVM/Robolectric test can fully observe. The unit test proves the command bitmask is correct; it cannot confirm the on-device tile actually renders 5 distinct buttons with Next visible on the reporter's device/Android version. That needs on-device/emulator verification, which isn't available in this environment. Flagging explicitly rather than claiming full verification.

Closes #509

… button

COMMAND_PLAY_PAUSE was left in availablePlayerCommands on the assumption
that the system tile's central glyph is driven only by
PlaybackStateCompat.state. On some devices/Android versions the system
also derives a standalone play/pause action bit from that command,
duplicating the custom-layout's own Play/Pause button and pushing "Next"
out of the five-slot row. Remove it, same treatment already given to the
overlapping seek/skip commands.

Closes #509
@github-actions
github-actions Bot marked this pull request as ready for review August 24, 2026 09:30
@github-actions

Copy link
Copy Markdown
Contributor

Status update: implementation complete, PR marked ready for review.

Local verification (mirroring CI):

  • `./gradlew :feature:player:testDebugUnitTest` — pass, including the new regression test
  • `./gradlew testDebugUnitTest --continue` (full repo, same command `jvm-tests.yml` runs) — pass
  • New test confirmed red on the pre-fix code / green after the fix (per AGENTS.md's "prove a new test can fail")
  • Re-fetched `dev` immediately before marking ready — no new commits since this branch was cut, nothing to rebase

Note: GitHub Actions checks on this PR still show the stale "skipping" results from when it was opened as a draft — no new workflow run appears to have been triggered by the ready_for_review transition in this environment, so I can't point to a live green CI run here. The local runs above use the identical commands CI itself invokes (jvm-tests.yml's ./gradlew testDebugUnitTest --continue), so I'm treating that as the best available signal in place of it.

@github-actions github-actions Bot added the risk:low Principal review classified this PR as low risk label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

QA verification — PR #511 vs issue #509

Acceptance criteria (bug report — no explicit checklist, so: repro no longer reproduces + regression test proves it):

  • ✅ Root cause matches issue Android lockscreen media notification shows Play button twice, missing Next #509 exactly: Player.COMMAND_PLAY_PAUSE was left in availablePlayerCommands in LibravaultMediaCallback.onConnect, on the assumption the system tile's central glyph is driven only by PlaybackStateCompat.state. The fix adds .remove(Player.COMMAND_PLAY_PAUSE) to the Player.Commands.Builder chain — the exact "suggested triage direction" from the issue, with the same treatment already given to the seek/skip commands.
  • ✅ Regression test added (LibravaultMediaCallbackConnectTest), and it demonstrably works as a regression guard — see below.
  • ⚠️ On-device/emulator confirmation that the tile now renders exactly 5 distinct buttons with Next visible is not possible in this environment (no emulator/device access here either). The PR description flags this caveat itself. The unit test proves the command bitmask is correct (the actual mechanism the issue's own triage direction identified as the bug), which is the strongest verification available outside real hardware.

What I ran:

  • ./gradlew :feature:player:testDebugUnitTest --continue → BUILD SUCCESSFUL, all tests pass, including the two new tests in LibravaultMediaCallbackConnectTest (onConnect excludes COMMAND_PLAY_PAUSE... and onConnect still excludes the seek and skip commands...).
  • Confirmed the new test is a real regression guard, not a trivially-green mock: checked out HEAD~1's version of LibravaultMediaCallback.kt (pre-fix, still has COMMAND_PLAY_PAUSE in availablePlayerCommands) and re-ran just LibravaultMediaCallbackConnectTest against it → the new "excludes COMMAND_PLAY_PAUSE" test FAILED (java.lang.AssertionError) exactly as expected, while the "still excludes seek/skip" test passed. Restored the fixed file afterward (working tree confirmed clean).
  • Checked for regressions: LibravaultMediaCallbackDispatchTest's PLAY_PAUSE resumes/pauses playback tests cover the custom session command CustomCommandActions.PLAY_PAUSE dispatch path (tap-to-play/pause), which is untouched by this change — the removed Player.COMMAND_PLAY_PAUSE only affects the redundant standard-action bitmask, not the custom-layout button's dispatch. No other file in the repo references Player.COMMAND_PLAY_PAUSE.

AGENTS.md conventions:

  • ✅ Regression test present for a bug fix, as required.
  • ✅ Test uses JUnit4 + Robolectric (@RunWith(RobolectricTestRunner::class)), matching the established pattern for Android-framework-touching tests in this same module (e.g. PlaybackServiceTest.kt), not a violation of the JUnit5-by-default convention.
  • ✅ Branch naming (fix/lockscreen-duplicate-play-button) and commit message (fix(player): ..., Closes #509) follow repo conventions.
  • ✅ No hardcoded versions touched; diff is scoped to the one source file + one new test file.

No gaps found. This is a low-risk, well-targeted fix that matches the issue's own root-cause analysis and suggested direction, with a test that is proven (not assumed) to catch the regression.

QA verdict: PASS

@github-actions github-actions Bot removed the status:needs-qa PR open, awaiting qa-agent verification label Aug 24, 2026
@libravault-pipeline-bot libravault-pipeline-bot Bot added the status:needs-review QA passed, awaiting principal-review-agent label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pipeline is at capacity (3/3 active runs) — skipping this review run. Re-apply status:needs-review once activity settles, or re-trigger manually via workflow_dispatch.

@libravault-pipeline-bot libravault-pipeline-bot Bot added status:needs-review QA passed, awaiting principal-review-agent and removed status:needs-review QA passed, awaiting principal-review-agent labels Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Human-merge sweep: this PR's last comment is a Phase 4 concurrency-cap skip (Pipeline is at capacity (3/3 active runs) — skipping this review run) with no later verdict/progress comment and no label change since — a capacity race, not a real question. Re-applying status:needs-review now that a slot should be free, per this routine's Part 4.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Principal review — verdict: human-merge

Risk label check: risk:low is correctly applied — diff is 110 lines (102 additions/8 deletions, well under the 400-line max_auto_mergeable_diff_lines threshold), and neither changed file (feature/player/.../LibravaultMediaCallback.kt, plus a new test file) matches any sensitive_paths glob in .github/agent-policy.yml. No status:blocked on the PR or issue #509. No new networking dependency/call. Nothing on sensitive_paths touched.

Despite that, this gets human-merge because of a CONFIRMED correctness finding below — per the persona's policy, a CONFIRMED finding forces human-merge regardless of risk tier.

CONFIRMED: this fix almost certainly breaks external play/pause control (Bluetooth, headset button, Android Auto, Assistant) — filed as #523

The change removes Player.COMMAND_PLAY_PAUSE from the availablePlayerCommands bitmask onConnect returns for every connecting controller. I verified against the exact androidx.media3:media3-session:1.11.0 source this repo pins (gradle/libs.versions.toml) rather than speculating:

  • MediaSessionLegacyStub.onPlay()/onPause() — the callbacks invoked for Bluetooth AVRCP, wired-headset media buttons, Android Auto, Google Assistant voice commands, and Wear OS (anything going through the legacy MediaSessionCompat.Callback bridge Media3 auto-creates) — both route through dispatchSessionTaskWithPlayerCommand(COMMAND_PLAY_PAUSE, ...), which does if (!connectedControllersManager.isPlayerCommandAvailable(controller, command)) { ...; return; } (MediaSessionLegacyStub.java ~line 863) — a silent no-op, no exception, no other signal.
  • isPlayerCommandAvailable (ConnectedControllersManager.java ~line 307) checks info.playerCommands, which is exactly the Player.Commands set onConnect returned for that controller at connect time. This app's onConnect doesn't branch by controller identity, so the legacy-stub controller gets the identical restricted set — now with no COMMAND_PLAY_PAUSE.

Net effect: pressing play/pause on a Bluetooth headset or car head unit, a wired remote, Android Auto's own UI, or saying "Hey Google, pause" would all silently stop working — only tapping the on-screen custom Play/Pause button in the notification/lockscreen tile would still respond (it dispatches via the custom SessionCommand-based PLAY_PAUSE action in onCustomCommand, unaffected by this bitmask). For an audiobook app routinely used hands-free, that's a materially worse regression than the cosmetic duplicate-button bug being fixed.

This is exactly the risk issue #509's own "suggested triage direction" flagged as needing verification before merging ("verify... whether that breaks something else the KDoc's assumption was protecting against... needs on-device verification"). The PR's "Verification caveat" section only addresses whether the tile visually renders 5 buttons — it doesn't mention this functional path, and no on-device/emulator check of external transport controls was done. The new LibravaultMediaCallbackConnectTest only asserts the bitmask no longer contains COMMAND_PLAY_PAUSE — it can't observe this regression (Robolectric doesn't model the legacy compat dispatch path), so it would pass either way.

Suggested direction (left for the follow-up, not resolved here): keep COMMAND_PLAY_PAUSE available and fix the duplicate-glyph/misplaced-Next issue via CommandButton/setMediaButtonPreferences slot control instead — the newer Media3 API this file's own KDoc already notes it hasn't migrated to. Full writeup and code references in #523.

Other checks (no findings)

  • CI vs local claims: the real jvm-tests.yml "Unit & Integration Tests (JVM)" job never actually ran for this PR's commit — it was skipped both while the PR was a draft and (per the dev agent's own comment) again on the ready_for_review transition, which apparently didn't retrigger the workflow in this environment. Both the dev agent's and QA agent's "tests pass" claims rest solely on self-reported local ./gradlew runs, not a live CI run. I ran ./gradlew :feature:player:testDebugUnitTest --continue myself in this review and confirmed BUILD SUCCESSFUL, with both new tests in LibravaultMediaCallbackConnectTest genuinely executing and passing (test-results XML checked, not just console output). So the underlying claim holds up under independent verification — flagging the CI-didn't-run gap for visibility, not as a blocker.
  • AGENTS.md test conventions: the new test uses JUnit4 (org.junit.Test + RobolectricTestRunner) rather than this repo's default JUnit5 — but that matches the existing precedent for Robolectric tests in this same module (PlaybackServiceTest.kt uses the identical pattern), so not a deviation.
  • No sensitive paths, no new dependencies, diff well under the size threshold — risk:low is the right mechanical classification, independent of the finding above.

Closes nothing by itself — routing to a human per policy on the CONFIRMED finding.

@github-actions github-actions Bot added status:needs-human-merge Principal review done, requires human merge decision and removed status:needs-review QA passed, awaiting principal-review-agent labels Aug 24, 2026
@github-actions
github-actions Bot merged commit 15817ea into dev Aug 24, 2026
28 checks passed
@github-actions
github-actions Bot deleted the fix/lockscreen-duplicate-play-button branch August 24, 2026 16:42
github-actions Bot added a commit that referenced this pull request Aug 24, 2026
 and #5 (#536)

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Principal review classified this PR as low risk status:needs-human-merge Principal review done, requires human merge decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android lockscreen media notification shows Play button twice, missing Next

0 participants