OSDN Git Service

Resolve AVRCP IOP issues
authorZhihai Xu <zhihaixu@google.com>
Fri, 12 Apr 2013 01:14:53 +0000 (18:14 -0700)
committerZhihai Xu <zhihaixu@google.com>
Fri, 12 Apr 2013 01:14:53 +0000 (18:14 -0700)
This patch has the following fixes
1. Track number should be 0xFFFFFFFF when no track is currently selected
2. When no track is currently selected set play state as stopped
3. Track number sent in the correct byte order

issue 8586495

Change-Id: I2be583d1e87a39015dff605c7442ca658a10b2e2

src/com/android/bluetooth/a2dp/Avrcp.java

index 3e3ded1..0a5a69e 100755 (executable)
@@ -93,7 +93,7 @@ final class Avrcp {
         mCurrentPlayState = RemoteControlClient.PLAYSTATE_NONE; // until we get a callback
         mPlayStatusChangedNT = NOTIFICATION_TYPE_CHANGED;
         mTrackChangedNT = NOTIFICATION_TYPE_CHANGED;
-        mTrackNumber = 0L;
+        mTrackNumber = -1L;
         mCurrentPosMs = RemoteControlClient.PLAYBACK_POSITION_INVALID;
         mPlayStartTimeMs = -1L;
         mSongLengthMs = 0L;
@@ -411,8 +411,9 @@ final class Avrcp {
 
     private void sendTrackChangedRsp() {
         byte[] track = new byte[TRACK_ID_SIZE];
+        /* track is stored in big endian format */
         for (int i = 0; i < TRACK_ID_SIZE; ++i) {
-            track[i] = (byte) (mTrackNumber >> (8 * i));
+            track[i] = (byte) (mTrackNumber >> (56 - 8 * i));
         }
         registerNotificationRspTrackChangeNative(mTrackChangedNT, track);
     }
@@ -469,6 +470,7 @@ final class Avrcp {
                 break;
 
             case RemoteControlClient.PLAYSTATE_STOPPED:
+            case RemoteControlClient.PLAYSTATE_NONE:
                 playStatus = PLAYSTATUS_STOPPED;
                 break;
 
@@ -487,7 +489,6 @@ final class Avrcp {
                 break;
 
             case RemoteControlClient.PLAYSTATE_ERROR:
-            case RemoteControlClient.PLAYSTATE_NONE:
                 playStatus = PLAYSTATUS_ERROR;
                 break;