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

Commit 1bb12871 authored by Roman Birg's avatar Roman Birg
Browse files

RemoteController: extract interface conflicting with CTS test (1/2)



android.media.cts.RemoteControllerTest#testOnClientUpdateListenerUnchanged
will fail because it expects no extra methods to be added to the
listeners and the current AVRCP impl simply appended methods to that
listener. In 13 this was fixed by creating a separate listener for those
callbacks. Backport that listener to fix the test.

Ticket: HAM-1300, CYNGNOS-2716

Change-Id: I05bdac4fcc581c09e03fe7feb216d012a4c5e62b
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
(cherry picked from commit 4b2c7d06)
parent 169126f4
Loading
Loading
Loading
Loading
+55 −39
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import java.util.List;
    private boolean mIsRegistered = false;
    private PendingIntent mClientPendingIntentCurrent;
    private OnClientUpdateListener mOnClientUpdateListener;
    private OnClientAvrcpUpdateListener mOnClientAvrcpUpdateListener;
    private PlaybackInfo mLastPlaybackInfo;
    private int mArtworkWidth = -1;
    private int mArtworkHeight = -1;
@@ -150,12 +151,31 @@ import java.util.List;
        }
    }

    /**
     * @hide
     */
    public RemoteController(Context context, OnClientUpdateListener updateListener, Looper looper,
            OnClientAvrcpUpdateListener avrcpUpdateListener) throws IllegalArgumentException {
        this(context, updateListener, looper);
        mOnClientAvrcpUpdateListener = avrcpUpdateListener;
    }

    /**
     * @hide
     */
    public interface OnClientAvrcpUpdateListener {
        public void onClientFolderInfoBrowsedPlayer(String stringUri);
        public void onClientUpdateNowPlayingEntries(long[] playList);
        public void onClientNowPlayingContentChange();
        public void onClientPlayItemResponse(boolean success);
    };

    /**
    * Interface definition for the callbacks to be invoked whenever media events, metadata
    * and playback status are available.
    */
    public interface OnClientUpdateListener {

        /**
         * Called whenever all information, previously received through the other
         * methods of the listener, is no longer valid and is about to be refreshed.
@@ -165,7 +185,6 @@ import java.util.List;
         *     is available.
         */
        public void onClientChange(boolean clearing);

        /**
         * Called whenever the playback state has changed.
         * It is called when no information is known about the playback progress in the media and
@@ -206,26 +225,6 @@ import java.util.List;
         */
        public void onClientMetadataUpdate(MetadataEditor metadataEditor);

        /**
         * @hide
         */
        public void onClientFolderInfoBrowsedPlayer(String stringUri);

        /**
         * @hide
         */
        public void onClientUpdateNowPlayingEntries(long[] playList);

        /**
         * @hide
         */
        public void onClientNowPlayingContentChange();

        /**
         * @hide
         */
        public void onClientPlayItemResponse(boolean success);

    };


@@ -1176,15 +1175,19 @@ import java.util.List;
     */
    public void onFolderInfoBrowsedPlayer(String stringUri) {
        Log.d(TAG, "RemoteController: onFolderInfoBrowsedPlayer");
        final OnClientUpdateListener l;
        final OnClientAvrcpUpdateListener l;

        synchronized(mInfoLock) {
            l = mOnClientUpdateListener;
            l = mOnClientAvrcpUpdateListener;
        }

        try {
            if (l != null) {
                l.onClientFolderInfoBrowsedPlayer(stringUri);
            }
        } catch (Exception e) {
            Log.e(TAG, "Error Updating AVRCP on receiving Browsed player response", e);
        }
    }

    /**
@@ -1192,14 +1195,19 @@ import java.util.List;
     */
    public void onNowPlayingEntriesUpdate(long[] playList) {
        Log.d(TAG, "RemoteController: onUpdateNowPlayingEntries");
        final OnClientUpdateListener l;
        final OnClientAvrcpUpdateListener l;

        synchronized(mInfoLock) {
            l = mOnClientUpdateListener;
            l = mOnClientAvrcpUpdateListener;
        }

        try {
            if (l != null) {
                l.onClientUpdateNowPlayingEntries(playList);
            }
        } catch (Exception e) {
            Log.e(TAG, "Error Updating AVRCP on receiving Now Playing Entries", e);
        }
    }

    /**
@@ -1207,15 +1215,19 @@ import java.util.List;
     */
    public void onNowPlayingContentChange() {
        Log.d(TAG, "RemoteController: onNowPlayingContentChange");
        final OnClientUpdateListener l;
        final OnClientAvrcpUpdateListener l;

        synchronized(mInfoLock) {
            l = mOnClientUpdateListener;
            l = mOnClientAvrcpUpdateListener;
        }

        try {
            if (l != null) {
                l.onClientNowPlayingContentChange();
            }
        } catch (Exception e) {
            Log.e(TAG, "Error Updating AVRCP on Now Playing Content Change", e);
        }
    }

    /**
@@ -1223,15 +1235,19 @@ import java.util.List;
     */
    public void onSetPlayItemResponse(boolean success) {
        Log.d(TAG, "RemoteController: onPlayItemResponse");
        final OnClientUpdateListener l;
        final OnClientAvrcpUpdateListener l;

        synchronized(mInfoLock) {
            l = mOnClientUpdateListener;
            l = mOnClientAvrcpUpdateListener;
        }

        try {
            if (l != null) {
                l.onClientPlayItemResponse(success);
            }
        } catch (Exception e) {
            Log.e(TAG, "Error Updating AVRCP on receiving Play Item response", e);
        }
    }

    //==================================================
+0 −12
Original line number Diff line number Diff line
@@ -138,18 +138,6 @@ public class KeyguardTransportControlView extends FrameLayout {
        public void onClientMetadataUpdate(RemoteController.MetadataEditor metadataEditor) {
            updateMetadata(metadataEditor);
        }

        @Override
        public void onClientFolderInfoBrowsedPlayer(String stringUri) { }

        @Override
        public void onClientUpdateNowPlayingEntries(long[] playList) { }

        @Override
        public void onClientNowPlayingContentChange() { }

        @Override
        public void onClientPlayItemResponse(boolean success) { }
    };

    private class UpdateSeekBarRunnable implements  Runnable {