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

Commit 3261b537 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

RemoteControlClient receives playback position change requests

RemoteControlClient defines two listener interfaces for playback
  position, one to let the framework query the current playback
  position, the other to request playback to seek to a given
  position.

Updated IRemoteControlDisplay interface to support passing info
  about whether the user of RemoteControlClient can provide a
  playback position, and receive a new one.
Updated implementations of IRemoteControlDisplay to new
  interface.

Bug 8120740

Change-Id: I1a5a969da4d0f8c9ad27f691919dd08f8653982b
parent 73882cf4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ public class TransportControlView extends FrameLayout implements OnClickListener
            }
        }

        public void setTransportControlFlags(int generationId, int flags) {
        public void setTransportControlInfo(int generationId, int flags, int posCapabilities) {
            Handler handler = mLocalHandler.get();
            if (handler != null) {
                handler.obtainMessage(MSG_SET_TRANSPORT_CONTROLS, generationId, flags)
+20 −0
Original line number Diff line number Diff line
@@ -2273,6 +2273,26 @@ public class AudioManager {
        }
    }

    /**
     * @hide
     * Request the user of a RemoteControlClient to seek to the given playback position.
     * @param generationId the RemoteControlClient generation counter for which this request is
     *         issued. Requests for an older generation than current one will be ignored.
     * @param timeMs the time in ms to seek to, must be positive.
     */
    public void setRemoteControlClientPlaybackPosition(int generationId, long timeMs) {
        if (timeMs < 0) {
            return;
        }
        IAudioService service = getService();
        try {
            service.setRemoteControlClientPlaybackPosition(generationId, timeMs);
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in setRccPlaybackPosition("+ generationId + ", "
                    + timeMs + ")", e);
        }
    }

    /**
     *  @hide
     *  Reload audio settings. This method is called by Settings backup
+30 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
    private static final int MSG_BROADCAST_BT_CONNECTION_STATE = 30;
    private static final int MSG_UNLOAD_SOUND_EFFECTS = 31;
    private static final int MSG_RCC_NEW_PLAYBACK_STATE = 32;

    private static final int MSG_RCC_SEEK_REQUEST = 33;

    // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
    // persisted
@@ -4919,6 +4919,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
        }
    };

    /**
     * Synchronization on mCurrentRcLock always inside a block synchronized on mRCStack
     */
    private final Object mCurrentRcLock = new Object();
    /**
     * The one remote control client which will receive a request for display information.
@@ -5190,6 +5193,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                        "  -- volMax: " + rcse.mPlaybackVolumeMax +
                        "  -- volObs: " + rcse.mRemoteVolumeObs);
            }
            synchronized(mCurrentRcLock) {
                pw.println("\nCurrent remote control generation ID = " + mCurrentRcClientGen);
            }
        }
        synchronized (mMainRemote) {
            pw.println("\nRemote Volume State:");
@@ -6018,6 +6024,29 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
        }
    }

    public void setRemoteControlClientPlaybackPosition(int generationId, long timeMs) {
        sendMsg(mAudioHandler, MSG_RCC_SEEK_REQUEST, SENDMSG_QUEUE, generationId /* arg1 */,
                0 /* arg2 ignored*/, new Long(timeMs) /* obj */, 0 /* delay */);
    }

    public void onSetRemoteControlClientPlaybackPosition(int generationId, long timeMs) {
        if(DEBUG_RC) Log.d(TAG, "onSetRemoteControlClientPlaybackPosition(genId=" + generationId +
                ", timeMs=" + timeMs + ")");
        synchronized(mRCStack) {
            synchronized(mCurrentRcLock) {
                if ((mCurrentRcClient != null) && (mCurrentRcClientGen == generationId)) {
                    // tell the current client to seek to the requested location
                    try {
                        mCurrentRcClient.seekTo(generationId, timeMs);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Current valid remote client is dead: "+e);
                        mCurrentRcClient = null;
                    }
                }
            }
        }
    }

    public void setPlaybackInfoForRcc(int rccId, int what, int value) {
        sendMsg(mAudioHandler, MSG_RCC_NEW_PLAYBACK_INFO, SENDMSG_QUEUE,
                rccId /* arg1 */, what /* arg2 */, Integer.valueOf(value) /* obj */, 0 /* delay */);
+21 −6
Original line number Diff line number Diff line
@@ -126,11 +126,6 @@ interface IAudioService {
    oneway void registerMediaButtonEventReceiverForCalls(in ComponentName c);
    oneway void unregisterMediaButtonEventReceiverForCalls();

           int registerRemoteControlClient(in PendingIntent mediaIntent,
               in IRemoteControlClient rcClient, in String callingPackageName);
    oneway void unregisterRemoteControlClient(in PendingIntent mediaIntent,
           in IRemoteControlClient rcClient);

    /**
     * Register an IRemoteControlDisplay.
     * Notify all IRemoteControlClient of the new display and cause the RemoteControlClient
@@ -157,6 +152,26 @@ interface IAudioService {
     *   display doesn't need to receive artwork.
     */
    oneway void remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h);
    /**
     * Request the user of a RemoteControlClient to seek to the given playback position.
     * @param generationId the RemoteControlClient generation counter for which this request is
     *         issued. Requests for an older generation than current one will be ignored.
     * @param timeMs the time in ms to seek to, must be positive.
     */
     void setRemoteControlClientPlaybackPosition(int generationId, long timeMs);

    /**
     * Do not use directly, use instead
     *     {@link android.media.AudioManager#registerRemoteControlClient(RemoteControlClient)}
     */
    int registerRemoteControlClient(in PendingIntent mediaIntent,
            in IRemoteControlClient rcClient, in String callingPackageName);
    /**
     * Do not use directly, use instead
     *     {@link android.media.AudioManager#unregisterRemoteControlClient(RemoteControlClient)}
     */
    oneway void unregisterRemoteControlClient(in PendingIntent mediaIntent,
            in IRemoteControlClient rcClient);

    oneway void setPlaybackInfoForRcc(int rccId, int what, int value);
    void setPlaybackStateForRcc(int rccId, int state, long timeMs, float speed);
+1 −0
Original line number Diff line number Diff line
@@ -47,4 +47,5 @@ oneway interface IRemoteControlClient
    void   plugRemoteControlDisplay(IRemoteControlDisplay rcd, int w, int h);
    void unplugRemoteControlDisplay(IRemoteControlDisplay rcd);
    void setBitmapSizeForDisplay(IRemoteControlDisplay rcd, int w, int h);
    void seekTo(int clientGeneration, long timeMs);
}
 No newline at end of file
Loading