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

Commit 5d496788 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Make retrieving remote control client go through binder interface"

parents ffbf1756 ced110ec
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1755,6 +1755,26 @@ public class AudioManager {
        }
    }

    /**
     * @hide
     * Returns the current remote control client.
     * @param rcClientId the counter value that matches the extra
     *     {@link AudioManager#EXTRA_REMOTE_CONTROL_CLIENT} in the
     *     {@link AudioManager#REMOTE_CONTROL_CLIENT_CHANGED} event
     * @return the current IRemoteControlClient from which information to display on the remote
     *     control can be retrieved, or null if rcClientId doesn't match the current generation
     *     counter.
     */
    public IRemoteControlClient getRemoteControlClient(int rcClientId) {
        IAudioService service = getService();
        try {
            return service.getRemoteControlClient(rcClientId);
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in getRemoteControlClient "+e);
            return null;
        }
    }

    /**
     * @hide
     * Definitions of constants to be used in {@link android.media.IRemoteControlClient}.
+4 −4
Original line number Diff line number Diff line
@@ -2845,20 +2845,20 @@ public class AudioService extends IAudioService.Stub {
        }
    }

    private final static Object mCurrentRcLock = new Object();
    private final Object mCurrentRcLock = new Object();
    /**
     * The one remote control client to be polled for display information.
     * This object is never null, but its reference might.
     * Access protected by mCurrentRcLock.
     */
    private static SoftReference<IRemoteControlClient> mCurrentRcClientRef =
    private SoftReference<IRemoteControlClient> mCurrentRcClientRef =
            new SoftReference<IRemoteControlClient>(null);

    /**
     * A monotonically increasing generation counter for mCurrentRcClientRef.
     * Only accessed with a lock on mCurrentRcLock.
     */
    private static int mCurrentRcClientGen = 0;
    private int mCurrentRcClientGen = 0;

    /**
     * Returns the current remote control client.
@@ -2869,7 +2869,7 @@ public class AudioService extends IAudioService.Stub {
     *     control can be retrieved, or null if rcClientId doesn't match the current generation
     *     counter.
     */
    public static IRemoteControlClient getRemoteControlClient(int rcClientId) {
    public IRemoteControlClient getRemoteControlClient(int rcClientId) {
        synchronized(mCurrentRcLock) {
            if (rcClientId == mCurrentRcClientGen) {
                return mCurrentRcClientRef.get();
+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ interface IAudioService {
    void registerRemoteControlClient(in ComponentName eventReceiver,
           in IRemoteControlClient rcClient, in String callingPackageName);

    IRemoteControlClient getRemoteControlClient(in int rcClientId);

    void notifyRemoteControlInformationChanged(in ComponentName eventReceiver);

    void startBluetoothSco(IBinder cb);