fix(android): Wire stayAwake to ExoPlayer wake mode in audioplayers_android_exo#1998
Open
leonardo-oliveir-a wants to merge 1 commit into
Open
fix(android): Wire stayAwake to ExoPlayer wake mode in audioplayers_android_exo#1998leonardo-oliveir-a wants to merge 1 commit into
leonardo-oliveir-a wants to merge 1 commit into
Conversation
leonardo-oliveir-a
force-pushed
the
fix/exo-wake-mode
branch
from
June 10, 2026 09:28
3f128e7 to
5afd932
Compare
…ndroid_exo The exo implementation parses the stayAwake flag of AudioContextAndroid (the method channel requires it) but never consumes it. Media3 1.9.0 enables its wake lock by default while playing when no wake mode is set, but never the wifi lock — so with stayAwake there is currently no way to keep network playback alive once the device enters wifi power-save with the screen off (Media3 recommends WAKE_MODE_NETWORK for this). Map stayAwake=true to an explicit setWakeMode(C.WAKE_MODE_NETWORK) (partial wake lock + wifi lock, held only while actually playing), mirroring the stayAwake handling of audioplayers_android (MediaPlayer.setWakeMode in updateContext). Like there, the upgrade is one-way: WAKE_MODE_NONE is never set, since that would disable the default wake lock users currently rely on. Applied both at player creation and on context updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
leonardo-oliveir-a
force-pushed
the
fix/exo-wake-mode
branch
from
June 10, 2026 09:36
5afd932 to
0dca348
Compare
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.
Description
audioplayers_android_exoparses thestayAwakeflag ofAudioContextAndroid(the method channel even requires it), but never consumes it: theExoPlayeris built withoutsetWakeMode, sostayAwake: truesilently does nothing on the exo implementation.What Media3 1.9.0 does today when no wake mode is set (verified against the
media3-exoplayer:1.9.0bytecode anddumpsys poweron a physical device):ExoPlayerImplenables its wake lock by default while playing (ExoPlayer:WakeLockManagerpartial wake lock), but never the wifi lock —WifiLockManageris only enabled for an explicitWAKE_MODE_NETWORK. So network playback can still stall once the device enters wifi power-save with the screen off, andstayAwakegives users no way to opt into the behavior Media3 recommends for background network playback.This wires
stayAwake = trueto an explicitsetWakeMode(C.WAKE_MODE_NETWORK)(partial wake lock + wifi lock, held by ExoPlayer only while actually playing), mirroring thestayAwakehandling ofaudioplayers_android(MediaPlayer.setWakeModeinupdateContext). As there, the upgrade is one-way:WAKE_MODE_NONEis never set, since that would disable the default wake lock current users rely on —stayAwake: falsekeeps today's behavior, bit for bit.WAKE_MODE_NETWORKis used (rather thanWAKE_MODE_LOCAL) because the source type isn't known when the audio context is applied, and it is a strict superset. As with the MediaPlayer implementation, apps must declareandroid.permission.WAKE_LOCKfor the flag to take effect (Media3 docs).Applied both at player creation (initial context) and in
updateContext.Checklist
fix:,feat:,docs:etc).stayAwakedartdoc already describes this behavior.examples— no example change needed; testable in the example app by settingstayAwake: truein the audio context and streaming a URL with the screen off.Breaking Change
stayAwake: false— the default — is bit-for-bit unchanged.)How to validate
With
stayAwake: trueand a remote URL source playing:adb shell dumpsys powershows theExoPlayer:WakeLockManagerpartial wake lock anddumpsys wifishows theWifiLockManagerlock; both are released on pause. WithstayAwake: false, behavior is identical to current (default wake lock only, no wifi lock). (Running this validation on a physical device now — will post the dumpsys output here.)