-
Notifications
You must be signed in to change notification settings - Fork 769
commit dd8c4b8 seems to break Android 12(L) workaround by changing return value #3150
Copy link
Copy link
Open
Labels
Description
Version
Media3 main branch
More version details
Devices that reproduce the issue
N/A
Devices that do not reproduce the issue
N/A
Reproducible in the demo app?
Not tested
Reproduction steps
This issue only affects Android 12(L). They previously had a workaround in place to catch ForegroundServiceStartNotAllowedException which would then return false from onPlayRequested and not start playback, as that could happen even in valid situations.
media/libraries/session/src/main/java/androidx/media3/session/MediaSessionService.java
Lines 930 to 940 in 7ce3aa2
| @Override | |
| public boolean onPlayRequested(MediaSession session) { | |
| if (SDK_INT < 31 || SDK_INT >= 33) { | |
| return true; | |
| } | |
| // Check if service can start foreground successfully on Android 12 and 12L. | |
| if (!getMediaNotificationManager().isStartedInForeground()) { | |
| return onUpdateNotificationInternal(session, /* startInForegroundWhenPaused= */ true); | |
| } | |
| return true; | |
| } |
media/libraries/session/src/main/java/androidx/media3/session/MediaSessionImpl.java
Lines 1161 to 1165 in 7ce3aa2
| /* package */ void handleMediaControllerPlayRequest( | |
| ControllerInfo controller, boolean callOnPlayerInteractionFinished) { | |
| if (!onPlayRequested()) { | |
| // Request denied, e.g. due to missing foreground service abilities. | |
| return; |
Expected result
Before the commit, if player was on main thread:
- onUpdateNotification() throws ForegroundServiceStartNotAllowedException
- It's caught in onUpdateNotificationInternal(), false is returned
- Thus false is returned by onPlayRequested(), and in MediaSessionImpl.handleMediaControllerPlayRequest(), playback is not started. onForegroundServiceStartNotAllowedException() is called to inform the app
Actual result
- onUpdateNotification() throws ForegroundServiceStartNotAllowedException
- It's caught, but onUpdateNotificationInternal() still returns true
- Thus, in MediaSessionImpl.handleMediaControllerPlayRequest(), playback IS started, onForegroundServiceStartNotAllowedException() is called anyway
- Service will attempt to start playing despite not being in foreground
Media
N/A
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Reactions are currently unavailable