Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6fc2bc3 authored by Jin Seok Park's avatar Jin Seok Park Committed by Android (Google) Code Review
Browse files

Merge "[Media ML] Refactor MediaKeyDispatcher methods"

parents dabb0f38 ac061667
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public abstract class MediaKeyDispatcher {
     * Implement this to customize the logic for which MediaSession should consume which key event.
     *
     * Note: This session will have greater priority over the {@link PendingIntent} returned from
     * {@link #getCustomMediaButtonReceiver()}.
     * {@link #getMediaButtonReceiver(KeyEvent, int, boolean)}.
     *
     * @param keyEvent a non-null KeyEvent whose key code is one of the supported media buttons.
     * @param uid the uid value retrieved by calling {@link Binder#getCallingUid()} from
@@ -88,7 +88,7 @@ public abstract class MediaKeyDispatcher {
     * @return a {@link MediaSession.Token} instance that should consume the given key event.
     */
    @Nullable
    MediaSession.Token getCustomMediaSession(@NonNull KeyEvent keyEvent, int uid,
    MediaSession.Token getMediaSession(@NonNull KeyEvent keyEvent, int uid,
            boolean asSystemService) {
        return null;
    }
@@ -98,12 +98,13 @@ public abstract class MediaKeyDispatcher {
     * dispatched key event.
     *
     * Note: This pending intent will have lower priority over the {@link MediaSession.Token}
     * returned from {@link #getCustomMediaButtonReceiver()}.
     * returned from {@link #getMediaSession(KeyEvent, int, boolean)}.
     *
     * @return a {@link PendingIntent} instance that should receive the dispatched key event.
     */
    @Nullable
    PendingIntent getCustomMediaButtonReceiver() {
    PendingIntent getMediaButtonReceiver(@NonNull KeyEvent keyEvent, int uid,
            boolean asSystemService) {
        return null;
    }

+3 −2
Original line number Diff line number Diff line
@@ -2407,14 +2407,15 @@ public class MediaSessionService extends SystemService implements Monitor {
            MediaButtonReceiverHolder mediaButtonReceiverHolder = null;

            if (mCustomMediaKeyDispatcher != null) {
                MediaSession.Token token = mCustomMediaKeyDispatcher.getCustomMediaSession(
                MediaSession.Token token = mCustomMediaKeyDispatcher.getMediaSession(
                        keyEvent, uid, asSystemService);
                if (token != null) {
                    session = getMediaSessionRecordLocked(token);
                }

                if (session == null) {
                    PendingIntent pi = mCustomMediaKeyDispatcher.getCustomMediaButtonReceiver();
                    PendingIntent pi = mCustomMediaKeyDispatcher.getMediaButtonReceiver(keyEvent,
                            uid, asSystemService);
                    if (pi != null) {
                        mediaButtonReceiverHolder = MediaButtonReceiverHolder.create(mContext,
                                mCurrentFullUserRecord.mFullUserId, pi);