From dfa7338384734a837d4224c462882f7b2708233b Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Wed, 4 May 2016 09:45:52 -0700 Subject: Bluetooth: split out AVRCP remote interfaces (2/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: I063cc5c121beada981d5b97b3052acd6638e3a9a Signed-off-by: Roman Birg (cherry picked from commit 5aaa6203f124676957bf7acbc0d310d9b17f18fd) --- src/com/android/bluetooth/avrcp/Avrcp.java | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/com/android/bluetooth/avrcp/Avrcp.java b/src/com/android/bluetooth/avrcp/Avrcp.java index cdf26f92b..af27c3e34 100644 --- a/src/com/android/bluetooth/avrcp/Avrcp.java +++ b/src/com/android/bluetooth/avrcp/Avrcp.java @@ -79,6 +79,7 @@ public final class Avrcp { private AvrcpMessageHandler mHandler; private RemoteController mRemoteController; private RemoteControllerWeak mRemoteControllerCb; + private AvrcpRemoteControllerWeak mAvrcpRemoteControllerCb; private Metadata mMetadata; private int mTransportControlFlags; private int mCurrentPlayState; @@ -374,7 +375,9 @@ public final class Avrcp { } registerMediaPlayers(); mRemoteControllerCb = new RemoteControllerWeak(mHandler); - mRemoteController = new RemoteController(mContext, mRemoteControllerCb); + mAvrcpRemoteControllerCb = new AvrcpRemoteControllerWeak(mHandler); + mRemoteController = new RemoteController(mContext, mRemoteControllerCb, + null, mAvrcpRemoteControllerCb); mAudioManager.registerRemoteController(mRemoteController); mRemoteController.setSynchronizationMode(RemoteController.POSITION_SYNCHRONIZATION_CHECK); } @@ -650,6 +653,15 @@ public final class Avrcp { handler.obtainMessage(MSG_SET_METADATA, 0, 0, metadataEditor).sendToTarget(); } } + } + + private static class AvrcpRemoteControllerWeak implements + RemoteController.OnClientAvrcpUpdateListener { + private final WeakReference mLocalHandler; + + public AvrcpRemoteControllerWeak(Handler handler) { + mLocalHandler = new WeakReference(handler); + } @Override public void onClientFolderInfoBrowsedPlayer(String stringUri) { @@ -660,7 +672,7 @@ public final class Avrcp { if (ExternalPath.length < 4) { Log.d(TAG, "Wrong entries."); handler.obtainMessage(MSG_UPDATE_BROWSED_PLAYER_FOLDER, 0, 0, null) - .sendToTarget(); + .sendToTarget(); return; } Uri uri = Uri.parse(stringUri); @@ -676,14 +688,14 @@ public final class Avrcp { } mMediaUri = uri; if (handler != null) { - // Don't send the complete path to CK as few gets confused by that + // Don't send the complete path to CK as few gets confused by that // Send only the name of the root folder handler.obtainMessage(MSG_UPDATE_BROWSED_PLAYER_FOLDER, NUM_ROOT_ELEMENTS, - 1, SplitPath).sendToTarget(); + 1, SplitPath).sendToTarget(); } } else { handler.obtainMessage(MSG_UPDATE_BROWSED_PLAYER_FOLDER, 0, 0, null) - .sendToTarget(); + .sendToTarget(); } } @@ -693,7 +705,7 @@ public final class Avrcp { Handler handler = mLocalHandler.get(); if (handler != null) { handler.obtainMessage(MSG_NOW_PLAYING_ENTRIES_RECEIVED, 0, 0, - playList).sendToTarget(); + playList).sendToTarget(); } } @@ -712,7 +724,7 @@ public final class Avrcp { Handler handler = mLocalHandler.get(); if (handler != null) { handler.obtainMessage(MSG_PLAY_ITEM_RESPONSE, 0, 0, new Boolean(success)) - .sendToTarget(); + .sendToTarget(); } } } -- cgit v1.2.3