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

Commit 30e8bff1 authored by Jin Seok Park's avatar Jin Seok Park
Browse files

[Media ML] Add uid as parameter

Adding uid as a parameter to getSessionForKeyEvent since Samsung uses
uid from the method dispatchMediaKeyEvent to determine whether the
KeyEvent is received from a Bluetooth device or not.

Bug: 147027868
Test: build and boot
Change-Id: I7c542db9c0b6a2126c13e0b0730d93cb55d8a1d7
parent b40a716a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.server.media;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.media.session.ISessionManager;
import android.media.session.MediaSession;
import android.os.Binder;
import android.view.KeyEvent;

/**
@@ -36,12 +38,14 @@ public abstract class MediaKeyDispatcher {
     * Implement this to customize the logic for which MediaSession should consume which key event.
     *
     * @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
     *         {@link ISessionManager#dispatchMediaKeyEvent(String, boolean, KeyEvent, boolean)}
     * @param asSystemService {@code true} if the event came from the system service via hardware
     *         devices. {@code false} if the event came from the app process through key injection.
     * @return a {@link MediaSession.Token} instance that should consume the given key event.
     */
    @Nullable
    MediaSession.Token getSessionForKeyEvent(@NonNull KeyEvent keyEvent,
    MediaSession.Token getSessionForKeyEvent(@NonNull KeyEvent keyEvent, int uid,
            boolean asSystemService) {
        return null;
    }
+2 −2
Original line number Diff line number Diff line
@@ -774,7 +774,7 @@ public class MediaSessionService extends SystemService implements Monitor {
                Constructor constructor = customDispatcherClass.getDeclaredConstructor();
                mCustomMediaKeyDispatcher = (MediaKeyDispatcher) constructor.newInstance();
                mGetSessionForKeyEventMethod = customDispatcherClass.getDeclaredMethod(
                        "getSessionForKeyEvent", KeyEvent.class, boolean.class);
                        "getSessionForKeyEvent", KeyEvent.class, int.class, boolean.class);
            }
        } catch (ClassNotFoundException | InstantiationException | InvocationTargetException
                | IllegalAccessException | NoSuchMethodException e) {
@@ -2124,7 +2124,7 @@ public class MediaSessionService extends SystemService implements Monitor {
            if (mCustomMediaKeyDispatcher != null && mGetSessionForKeyEventMethod != null) {
                try {
                    Object tokenObject = mGetSessionForKeyEventMethod.invoke(
                            mCustomMediaKeyDispatcher, keyEvent, asSystemService);
                            mCustomMediaKeyDispatcher, keyEvent, uid, asSystemService);
                    if (tokenObject != null) {
                        session = getMediaSessionRecordLocked((MediaSession.Token) tokenObject);
                    }