MediaSession crashes with "packageName should be nonempty" when a media button event's sender package is empty
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design
Direzione di ricerca
Start with MediaSessionCompat.MediaSessionImplApi28.getCurrentControllerInfo() and the RemoteUserInfo constructor mentioned in the stack trace, then inspect related tests for controller information and media button events. Reproduce the empty-package case on Android 11 or 12, or with the described API 37 binder call. Done means the event no longer crashes the app and the sender is treated as an unknown, untrusted controller.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version
Media3 1.11.1
More version details
Also present on main.
MediaSessionLegacyStub.onMediaButtonEvent builds a ControllerInfo from sessionCompat.getCurrentControllerInfo(). On API 28+ that is MediaSessionImplApi28.getCurrentControllerInfo(), which wraps the platform's MediaSession.getCurrentControllerInfo() in new RemoteUserInfo(info), and that constructor throws IllegalArgumentException when the package name is empty. The constructor's own comment says the platform does not guarantee a non-empty package, and the platform does deliver one: on Android 11 and 12 MediaShellCommand dispatches keys with PACKAGE_NAME = "" ("This doesn't belongs to any package"), and MediaSessionService passes the caller's package to the session without checking it (still true on main). The exception is thrown on the session's application looper before MediaSession.Callback.onMediaButtonEvent runs, so an app cannot catch it.
Devices that reproduce the issue
- A JOYAR device on Android 11, in production (crash report below).
- Android emulator, API 37 (
sdk_gphone64_x86_64), sending the key with an empty package throughISessionManager.dispatchMediaKeyEvent(steps below).
Devices that do not reproduce the issue
The same emulator with the same call and package com.android.shell: the key is handled normally.
Reproducible in the demo app?
Not tested
Reproduction steps
- Play media in an app whose
MediaSessionis the media button session (adb shell dumpsys media_sessionshows it as the media button session). - Android 11 or 12:
adb shell cmd media_session dispatch play-pause.
Android 13 and later fill incom.android.shellfor the shell command, so call the binder method directly with an empty package (transaction 5 isdispatchMediaKeyEventon that API 37 image; the arguments are aKeyEventparcel, sent once with ACTION_DOWN and once with ACTION_UP):adb shell 'service call media_session 5 s16 "" i32 0 i32 1 i32 2 i32 4242 i32 -1 i32 257 i32 0 i32 -1 i32 0 i32 85 i32 0 i32 0 i32 0 i32 0 i64 0 i64 0 i32 -1 i32 0; service call media_session 5 s16 "" i32 0 i32 1 i32 2 i32 4243 i32 -1 i32 257 i32 0 i32 -1 i32 1 i32 85 i32 0 i32 0 i32 0 i32 0 i64 0 i64 0 i32 -1 i32 0'
Expected result
The key event is handled, or ignored, with the sender treated as an unknown, untrusted controller. MediaSessionImplBase already does this below API 24 by returning RemoteUserInfo.LEGACY_CONTROLLER.
Actual result
The app process dies:
FATAL EXCEPTION: ExoPlayerThread
java.lang.IllegalArgumentException: packageName should be nonempty
at androidx.media3.session.legacy.MediaSessionManager$RemoteUserInfo.<init>(MediaSessionManager.java:159)
at androidx.media3.session.legacy.MediaSessionCompat$MediaSessionImplApi28.getCurrentControllerInfo(MediaSessionCompat.java:2284)
at androidx.media3.session.legacy.MediaSessionCompat.getCurrentControllerInfo(MediaSessionCompat.java:678)
at androidx.media3.session.MediaSessionLegacyStub.onMediaButtonEvent(MediaSessionLegacyStub.java:537)
at androidx.media3.session.legacy.MediaSessionCompat$Callback$MediaSessionCallback.onMediaButtonEvent(MediaSessionCompat.java:1142)
at android.media.session.MediaSession$CallbackMessageHandler.handleMessage(MediaSession.java:1566)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
A suggested fix, in MediaSessionCompat.MediaSessionImplApi28.getCurrentControllerInfo():
android.media.session.MediaSessionManager.RemoteUserInfo info =
sessionFwk.getCurrentControllerInfo();
if (TextUtils.isEmpty(info.getPackageName())) {
return new RemoteUserInfo(RemoteUserInfo.LEGACY_CONTROLLER, info.getPid(), info.getUid());
}
return new RemoteUserInfo(info);
Media
Not applicable: any playing item reproduces it.
Bug Report
- You will email the zip file produced by
adb bugreportto [email protected] after filing this issue.
- Lingua principale
- Java
- Stelle
- 3.1k
- Fork
- 1k
- Merge medio
- 6g 4h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di androidx/media
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 4 giorni
-
CompositionPlayer.release() leaks its playback thread and FrameProcessor when no composition was setForse già presa @droid-girl l’ha presa 15 giorni fa. Apertaediting preview
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
androidx/media#3506 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 4 giorni
-
RemoteCastPlayer: receiver stalls in buffering when a single setActiveMediaTracks request changes the audio and the text track during playbackForse già presa @tanay187 l’ha presa 1 giorno fa. Apertabug needs triage
androidx/media#3561 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 4 giorni
-
StuckPlayerException: PLAYING_NO_PROGRESS (1.10.1)Forse già presa @tonihei l’ha presa 2 giorni fa. Apertaquestion
androidx/media#3559 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 4 giorni
-
[Cast] play() right after setMediaItems() is lost when the receiver already has media, so the new item loads pausedForse già presa @tanay187 l’ha presa 3 giorni fa. Aperta
androidx/media#3557 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di androidx/media
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
Vakore/ZappierGames#327 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexForse già presa @matthewalberto l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
mit-cml/appinventor-sources#4246 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CatalogueOfLife/backend#1713 ·
I maintainer di solito rispondono entro 1 giorno
-
SystemOneDecisionModel: allow sending chat_template_kwargs to /v1/systemoneForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertastatus: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
spring-projects/spring-ai#7427 ·
I maintainer di solito rispondono entro 1 giorno