Skip to content

fix(android): take over for untyped media and unknown AirPods state - #820

Open
Jeremy0538 wants to merge 2 commits into
librepods-org:mainfrom
Jeremy0538:fix/takeover-untyped-media-unknown-state
Open

Jeremy0538 wants to merge 2 commits into
librepods-org:mainfrom
Jeremy0538:fix/takeover-untyped-media-unknown-state

Conversation

@Jeremy0538

Copy link
Copy Markdown

Problem

Two cases where "take over when media starts" never fires, even with every Auto-Connect option enabled:

  1. Untyped media. Players that output through OpenSL ES (Poweramp, for example) report usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN. hasNewMusicOrMovie only accepts CONTENT_TYPE_MUSIC and CONTENT_TYPE_MOVIE, so pressing play there is never treated as media starting.
  2. Unknown AirPods state. While the AirPods are connected to another device, the phone can lose their BLE advertisements (All disappeared). The first status after they reappear can have an unmapped state byte, or there is no status yet. takeOver() then falls through to else -> false and logs Not taking over audio, airpods state takeover disabled.

Fix

  • MediaController: also count a USAGE_MEDIA stream with CONTENT_TYPE_UNKNOWN as music.
  • AirPodsService.takeOver(): for a state that isn't mapped (or a missing status), follow takeoverWhenMusic instead of refusing. Also log the state the decision was made on.

Evidence

  1. Before: Poweramp playing shows state:started attr:AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN, then Has new music or movie: false, and no takeover. After: Has new music or movie: true, then requesting takeOver.
  2. Before: New AirPods device detected → requesting takeOver → Not taking over audio, airpods state takeover disabled. After: the takeover goes ahead.

Tested on a Samsung Galaxy S26 Ultra running One UI 9 / Android 17 (unrooted, FOSS debug build) with AirPods Pro (A3064), handing over to and from a Linux laptop. Not tested on other devices or AirPods models.

Related

Two more bugs on the same path already have open PRs, which I hit as well and can confirm on this device: #790 (debounce drops the informative callback) and #792 (music not resumed after a takeover).

These changes were written with AI assistance (Claude Code) and debugged against logcat captures from the device above.

🤖 Generated with Claude Code

Jeremy0538 and others added 2 commits October 1, 2026 15:31
Players that output through OpenSL ES, such as Poweramp, report
USAGE_MEDIA with CONTENT_TYPE_UNKNOWN. Only MUSIC and MOVIE counted, so
playing music in them never triggered "take over when media starts".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While the AirPods are connected to another device the phone can lose
their BLE advertisements; the first one after they reappear can carry an
unmapped state byte, or there is no status at all. takeOver() then
refused with "airpods state takeover disabled" even with every takeover
option on. Fall back to takeoverWhenMusic and log the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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