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

Commit ced110ec authored by Neel Parekh's avatar Neel Parekh
Browse files

Make retrieving remote control client go through binder interface

The way the old way worked relied on the process retrieving the
current remote control client to be in the exact same process as
the AudioService.  This removes that dependency.

Change-Id: I1ba8bf32b61ec1e979ef7eee9661ba801aa19690
parent fb87cf60
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);