Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaLibraryService can't reject System UI playback resumption notification on API 30 #355

Closed
1 task
marcbaechinger opened this issue Apr 25, 2023 · 1 comment
Assignees
Labels

Comments

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Apr 25, 2023

Media3 Version

Media3 1.0.1

Devices that reproduce the issue

All devices on API 30

Devices that do not reproduce the issue

Devices on API below 30 and above API 30

Reproducible in the demo app?

Yes

Reproduction steps

To reproduce the issue, please follow these steps:

  • Launch the demo-session app.
  • Start playing any media.
  • Press the pause button.
  • Press the home button to exit the app.
  • Clear all apps from the recent apps list.
  • Attempt to play media from the stale notification by pressing the play button.
  • Wait for the error to occur in logcat.

See https://developer.android.com/guide/topics/media/media-controls#mediabrowserservice_implementation

Expected result

The System UI playback resumption notification is not shown.

Actual result

There is a System UI playback resumption notification after the demo app has been treminated.

It's currently not possible to do that with MediaLibraryService on API 30.

On API 30, allowing to connect a browser the MediaBrowserService seems sufficient for posting a playback resumption notification. onLoadChildre/onGetChildren is never called with package com.android.systemui:

04-25 08:19:18.466 10159   995   995 D MediaResumeListener: Checking for service component for androidx.media3.demo.session
04-25 08:19:18.467 10159   995  1093 D MediaResumeListener: Testing if we can connect to ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}
04-25 08:19:18.676 10175 10479 10479 D resumption: onConnect(): androidx.media3.demo.session
04-25 08:19:18.692 10175 10479 10479 D resumption: onPostConnect(): androidx.media3.demo.session
04-25 08:19:18.765 10175 10479 10479 D resumption: onConnect(): com.android.systemui
04-25 08:19:18.768 10175 10479 10479 D resumption: onGetLibraryRoot(): com.android.systemui
04-25 08:19:18.769 10159   995  1093 D ResumeMediaBrowser: connected
04-25 08:19:18.769 10159   995  1093 D MediaResumeListener: yes we can resume with ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}

On API 31, the browser with com.android.systemui insists in calling onLoadChildren/onGetChildren and checks whether there is a playable child.

04-25 08:14:04.449 10137  1030  1030 D MediaResumeListener: Checking for service component for androidx.media3.demo.session
04-25 08:14:04.450 10137  1030  1135 D MediaResumeListener: Testing if we can connect to ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}
04-25 08:14:04.658 10154 15670 15670 D resumption: onConnect(): androidx.media3.demo.session
04-25 08:14:04.667 10154 15670 15670 D resumption: onPostConnect(): androidx.media3.demo.session
04-25 08:14:04.747 10154 15670 15670 D resumption: onConnect(): com.android.systemui
04-25 08:14:04.749 10154 15670 15670 D resumption: onGetLibraryRoot(): com.android.systemui
04-25 08:14:04.751 10137  1030  1135 D ResumeMediaBrowser: Service connected for ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}
04-25 08:14:04.751 10137  1030  1135 D MediaResumeListener: Connected to ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}
04-25 08:14:05.106 10154 15670 15670 D resumption: onGetChildren(): com.android.systemui
04-25 08:14:05.142 10137  1030  1135 D ResumeMediaBrowser: Child found but not playable for ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}
04-25 08:14:05.142 10137  1030  1135 E MediaResumeListener: Cannot resume with ComponentInfo{androidx.media3.demo.session/androidx.media3.demo.session.PlaybackService}

Media

Any media of the session demo app

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@marcbaechinger marcbaechinger self-assigned this Apr 25, 2023
@marcbaechinger marcbaechinger changed the title MediaLibraryService can't reject SYstem UI playback resumption notification on API 30 MediaLibraryService can't reject System UI playback resumption notification on API 30 Apr 25, 2023
@marcbaechinger
Copy link
Contributor Author

marcbaechinger commented Apr 25, 2023

For Media3 1.0.1 there is no fix besides not adding

<action android:name="android.media.browse.MediaBrowserService"/>

to the intent filter of the MediaLibraryService. Please note that when android.media.browse.MediaBrowserService is not added clients like Android Auto can not discover the service either.

We are working on a fix for this.

icbaker pushed a commit that referenced this issue Apr 27, 2023
To reliably reject the System UI playback resumption notification on
all API levels (specifically API 30), the backward compatibility layer
needs to return `null` for the library root.

This is not possible in the Media3 implementation. This change allows
an app to return a `LibraryResult.ofError(RESULT_ERROR_NOT_SUPPORTED)`
that then is translated to return null by the backwards compatibility
layer.

Issue: #355
Issue: #167
Issue: #27

See https://developer.android.com/guide/topics/media/media-controls#mediabrowserservice_implementation

PiperOrigin-RevId: 527276529
icbaker pushed a commit that referenced this issue May 17, 2023
To reliably reject the System UI playback resumption notification on
all API levels (specifically API 30), the backward compatibility layer
needs to return `null` for the library root.

This is not possible in the Media3 implementation. This change allows
an app to return a `LibraryResult.ofError(RESULT_ERROR_NOT_SUPPORTED)`
that then is translated to return null by the backwards compatibility
layer.

Issue: #355
Issue: #167
Issue: #27

See https://developer.android.com/guide/topics/media/media-controls#mediabrowserservice_implementation

PiperOrigin-RevId: 527276529
(cherry picked from commit 7938978)
@androidx androidx locked and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant