AVRCP Controller getFolderItems
Fix the getFolderItems end item to be 0 indexed rather than 1 indexed.
This was causing fetching to end with an out of range error.
Bug: 113104809
Test: Perform browsing of folders.
Change-Id: Ica7713f8cf2d6a08919df15965cc59b992206b4a
diff --git a/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java b/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
index a672255..f13f0c4 100644
--- a/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
+++ b/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java
@@ -564,21 +564,21 @@
}
private void fetchContents(BrowseTree.BrowseNode target) {
+ int start = target.getChildrenCount();
+ int end = Math.min(target.getExpectedChildren(), target.getChildrenCount()
+ + GET_FOLDER_ITEMS_PAGINATION_SIZE) - 1;
switch (target.getScope()) {
case AvrcpControllerService.BROWSE_SCOPE_PLAYER_LIST:
AvrcpControllerService.getPlayerListNative(mRemoteDevice.getBluetoothAddress(),
- 0, 255);
+ start, end);
break;
case AvrcpControllerService.BROWSE_SCOPE_NOW_PLAYING:
AvrcpControllerService.getNowPlayingListNative(
- mRemoteDevice.getBluetoothAddress(), target.getChildrenCount(),
- Math.min(target.getExpectedChildren(), target.getChildrenCount()
- + GET_FOLDER_ITEMS_PAGINATION_SIZE - 1));
+ mRemoteDevice.getBluetoothAddress(), start, end);
break;
case AvrcpControllerService.BROWSE_SCOPE_VFS:
AvrcpControllerService.getFolderListNative(mRemoteDevice.getBluetoothAddress(),
- target.getChildrenCount(), Math.min(target.getExpectedChildren(),
- target.getChildrenCount() + GET_FOLDER_ITEMS_PAGINATION_SIZE - 1));
+ start, end);
break;
default:
Log.e(STATE_TAG, "Scope " + target.getScope() + " cannot be handled here.");
diff --git a/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java b/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java
index 1fb498a..7f4f3bf 100644
--- a/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java
+++ b/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java
@@ -63,6 +63,7 @@
mRootNode = new BrowseNode(new MediaItem(new MediaDescription.Builder().setExtras(mdBundle)
.setMediaId(ROOT).setTitle(ROOT).build(), MediaItem.FLAG_BROWSABLE));
mRootNode.mBrowseScope = AvrcpControllerService.BROWSE_SCOPE_PLAYER_LIST;
+ mRootNode.setExpectedChildren(255);
Bundle upnodeBundle = new Bundle();
upnodeBundle.putString(AvrcpControllerService.MEDIA_ITEM_UID_KEY, UP);