MediaSession crashes with "packageName should be nonempty" when a media button event's sender package is empty
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 3.1k
- Fork
- 1k
- Merge trung bình
- 6 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của androidx/media
-
bug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 4 ngày
-
CompositionPlayer.release() leaks its playback thread and FrameProcessor when no composition was setCó thể đã có người làm @droid-girl đã nhận 15 ngày trước. Đang mởediting preview
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
androidx/media#3506 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
RemoteCastPlayer: receiver stalls in buffering when a single setActiveMediaTracks request changes the audio and the text track during playbackCó thể đã có người làm @tanay187 đã nhận 1 ngày trước. Đang mởbug needs triage
androidx/media#3561 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
StuckPlayerException: PLAYING_NO_PROGRESS (1.10.1)Có thể đã có người làm @tonihei đã nhận 2 ngày trước. Đang mởquestion
androidx/media#3559 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[Cast] play() right after setMediaItems() is lost when the receiver already has media, so the new item loads pausedCó thể đã có người làm @tanay187 đã nhận 3 ngày trước. Đang mở
androidx/media#3557 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của androidx/media
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
Vakore/ZappierGames#327 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexCó thể đã có người làm @matthewalberto đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
mit-cml/appinventor-sources#4246 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CatalogueOfLife/backend#1713 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SystemOneDecisionModel: allow sending chat_template_kwargs to /v1/systemoneCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởstatus: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
spring-projects/spring-ai#7427 ·
Maintainer thường phản hồi trong vòng 1 ngày