fix(android): take over for untyped media and unknown AirPods state - #820
Open
Jeremy0538 wants to merge 2 commits into
Open
Jeremy0538 wants to merge 2 commits into
Jeremy0538 wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two cases where "take over when media starts" never fires, even with every Auto-Connect option enabled:
usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN.hasNewMusicOrMovieonly acceptsCONTENT_TYPE_MUSICandCONTENT_TYPE_MOVIE, so pressing play there is never treated as media starting.All disappeared). The first status after they reappear can have an unmapped state byte, or there is no status yet.takeOver()then falls through toelse -> falseand logsNot taking over audio, airpods state takeover disabled.Fix
MediaController: also count aUSAGE_MEDIAstream withCONTENT_TYPE_UNKNOWNas music.AirPodsService.takeOver(): for a state that isn't mapped (or a missing status), followtakeoverWhenMusicinstead of refusing. Also log the state the decision was made on.Evidence
state:started attr:AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN, thenHas new music or movie: false, and no takeover. After:Has new music or movie: true, thenrequesting takeOver.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