Loading android/app/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,16 @@ class MediaPlayerWrapper { } Metadata getCurrentMetadata() { // Try to use the now playing list if the information exists. if (getActiveQueueID() != -1) { for (Metadata data : getCurrentQueue()) { if (data.mediaId.equals(Util.NOW_PLAYING_PREFIX + getActiveQueueID())) { d("getCurrentMetadata: Using playlist data: " + data.toString()); return data.clone(); } } } return Util.toMetadata(getMetadata()); } Loading android/app/src/com/android/bluetooth/newavrcp/helpers/Util.java +5 −2 Original line number Diff line number Diff line Loading @@ -209,8 +209,11 @@ class Util { if (items == null) return list; for (MediaSession.QueueItem item : items) { list.add(toMetadata(item)); for (int i = 0; i < items.size(); i++) { Metadata data = toMetadata(items.get(i)); data.trackNum = "" + (i + 1); data.numTracks = "" + items.size(); list.add(data); } return list; Loading android/app/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,28 @@ public class MediaPlayerWrapperTest { verify(mFailHandler, never()).onTerribleFailure(any(), any(), anyBoolean()); } /* * This test checks whether getCurrentMetadata() returns the corresponding item from * the now playing list instead of the current metadata if there is a match. */ @Test public void testCurrentSongFromQueue() { // Create the wrapper object and register the looper with the timeout handler TestLooperManager looperManager = new TestLooperManager(mThread.getLooper()); mTestState.setActiveQueueItemId(101); doReturn(mTestState.build()).when(mMockController).getPlaybackState(); MediaPlayerWrapper wrapper = MediaPlayerWrapper.wrap(mMockController, mThread.getLooper()); wrapper.registerCallback(mTestCbs); // The current metadata doesn't contain track number info so check that // field to see if the correct data was used. Assert.assertEquals(wrapper.getCurrentMetadata().trackNum, "2"); Assert.assertEquals(wrapper.getCurrentMetadata().numTracks, "3"); } @Test public void testNullQueue() { // Create the wrapper object and register the looper with the timeout handler Loading Loading
android/app/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java +10 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,16 @@ class MediaPlayerWrapper { } Metadata getCurrentMetadata() { // Try to use the now playing list if the information exists. if (getActiveQueueID() != -1) { for (Metadata data : getCurrentQueue()) { if (data.mediaId.equals(Util.NOW_PLAYING_PREFIX + getActiveQueueID())) { d("getCurrentMetadata: Using playlist data: " + data.toString()); return data.clone(); } } } return Util.toMetadata(getMetadata()); } Loading
android/app/src/com/android/bluetooth/newavrcp/helpers/Util.java +5 −2 Original line number Diff line number Diff line Loading @@ -209,8 +209,11 @@ class Util { if (items == null) return list; for (MediaSession.QueueItem item : items) { list.add(toMetadata(item)); for (int i = 0; i < items.size(); i++) { Metadata data = toMetadata(items.get(i)); data.trackNum = "" + (i + 1); data.numTracks = "" + items.size(); list.add(data); } return list; Loading
android/app/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,28 @@ public class MediaPlayerWrapperTest { verify(mFailHandler, never()).onTerribleFailure(any(), any(), anyBoolean()); } /* * This test checks whether getCurrentMetadata() returns the corresponding item from * the now playing list instead of the current metadata if there is a match. */ @Test public void testCurrentSongFromQueue() { // Create the wrapper object and register the looper with the timeout handler TestLooperManager looperManager = new TestLooperManager(mThread.getLooper()); mTestState.setActiveQueueItemId(101); doReturn(mTestState.build()).when(mMockController).getPlaybackState(); MediaPlayerWrapper wrapper = MediaPlayerWrapper.wrap(mMockController, mThread.getLooper()); wrapper.registerCallback(mTestCbs); // The current metadata doesn't contain track number info so check that // field to see if the correct data was used. Assert.assertEquals(wrapper.getCurrentMetadata().trackNum, "2"); Assert.assertEquals(wrapper.getCurrentMetadata().numTracks, "3"); } @Test public void testNullQueue() { // Create the wrapper object and register the looper with the timeout handler Loading