AVRCP: Don't use the queue for current metadata

If many requests come for the current metadata and the queue is large,
AVRCP could end up using a lot of CPU time. Instead just use the players
current metadata. Note this could lead to metadata sync issues as we
aren't using the same source for queue information and current song
information, but that should be reflected in the logs in case the issue
arrises.

Bug: 112563625
Test: runtest bluetooth
Change-Id: Ia95e20cb78e53e8efb1548dfd95ae9f8afcfd4b4
diff --git a/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java b/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java
index d27054d..256e771 100644
--- a/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java
+++ b/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java
@@ -53,7 +53,6 @@
     private final Object mCallbackLock = new Object();
     private Callback mRegisteredCallback = null;
 
-
     protected MediaPlayerWrapper() {
         mCurrentData = new MediaData(null, null, null);
     }
@@ -122,16 +121,6 @@
     }
 
     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());
     }
 
diff --git a/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java b/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java
index cdae46b..85ad147 100644
--- a/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java
+++ b/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java
@@ -311,28 +311,6 @@
         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 testNullMetadata() {
         // Create the wrapper object and register the looper with the timeout handler