From 8a8111935121fda68dbafd8cfe43173bef947dfd Mon Sep 17 00:00:00 2001 From: Sanket Agarwal Date: Mon, 29 Aug 2016 10:28:03 -0700 Subject: [PATCH] [AVRCP1.6 CT] Add reply status to get_folder_items_callback. It is useful to know what error code the get_folder_items_cmd gets back with since it can help the UI decide if to keep fetching more. For ex. if the return code is out of range then the UI does not need to keep fetching anymore. This is useful for folders where we do not know the size before hand (Media Player List or Now Playing List). Bug: b/31253501 Change-Id: I0f43167d00bcf2e1e320be086fd9cacd163906a1 (cherry picked from commit e3a032a89ac2f20e96808fe2bded2c42fa3afb14) --- btif/src/btif_rc.cc | 14 +++++++++++--- stack/avrc/avrc_bld_ct.cc | 3 ++- stack/avrc/avrc_pars_ct.cc | 5 +++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/btif/src/btif_rc.cc b/btif/src/btif_rc.cc index f68b77bec..4abdfd521 100644 --- a/btif/src/btif_rc.cc +++ b/btif/src/btif_rc.cc @@ -4115,7 +4115,10 @@ static void handle_get_folder_items_response(tBTA_AV_META_MSG* pmeta_msg, } } - HAL_CBACK(bt_rc_ctrl_callbacks, get_folder_items_cb, &rc_addr, + HAL_CBACK(bt_rc_ctrl_callbacks, + get_folder_items_cb, + &rc_addr, + BTRC_STS_NO_ERROR, /* We want to make the ownership explicit in native */ (const btrc_folder_items_t*)btrc_items, item_count); BTIF_TRACE_DEBUG("%s HAL CBACK get_folder_items_cb finished", __func__); @@ -4124,6 +4127,11 @@ static void handle_get_folder_items_response(tBTA_AV_META_MSG* pmeta_msg, osi_free(btrc_items); } else { BTIF_TRACE_ERROR("%s: Error %d", __func__, p_rsp->status); + HAL_CBACK(bt_rc_ctrl_callbacks, + get_folder_items_cb, + &rc_addr, + (btrc_status_t) p_rsp->status, + NULL, 0); } } @@ -5006,7 +5014,7 @@ static bt_status_t set_browsed_player_cmd(bt_bdaddr_t* bd_addr, uint16_t id) { * **************************************************************************/ static bt_status_t get_folder_items_cmd(bt_bdaddr_t* bd_addr, uint8_t scope, - uint8_t start_item, uint8_t num_items) { + uint8_t start_item, uint8_t end_item) { BTIF_TRACE_DEBUG("%s", __func__); /* Check that both avrcp and browse channel are connected. */ btif_rc_device_cb_t* p_dev = btif_rc_get_device_by_bda(bd_addr); @@ -5027,7 +5035,7 @@ static bt_status_t get_folder_items_cmd(bt_bdaddr_t* bd_addr, uint8_t scope, avrc_cmd.get_items.status = AVRC_STS_NO_ERROR; avrc_cmd.get_items.scope = scope; avrc_cmd.get_items.start_item = start_item; - avrc_cmd.get_items.end_item = (start_item + num_items - 1); + avrc_cmd.get_items.end_item = end_item; avrc_cmd.get_items.attr_count = 0; /* p_attr_list does not matter hence */ if (AVRC_BldCommand(&avrc_cmd, &p_msg) == AVRC_STS_NO_ERROR) { diff --git a/stack/avrc/avrc_bld_ct.cc b/stack/avrc/avrc_bld_ct.cc index bb7afb1ff..2c3a4d82e 100644 --- a/stack/avrc/avrc_bld_ct.cc +++ b/stack/avrc/avrc_bld_ct.cc @@ -390,7 +390,8 @@ static tAVRC_STS avrc_bld_get_play_status_cmd(BT_HDR * p_pkt) *******************************************************************************/ static tAVRC_STS avrc_bld_get_folder_items_cmd(BT_HDR *p_pkt, const tAVRC_GET_ITEMS_CMD *cmd) { - AVRC_TRACE_API("avrc_bld_get_folder_items_cmd"); + AVRC_TRACE_API("avrc_bld_get_folder_items_cmd scope %d, start_item %d, end_item %d", + cmd->scope, cmd->start_item, cmd->end_item); uint8_t *p_start = (uint8_t *)(p_pkt + 1) + p_pkt->offset; /* This is where the PDU specific for AVRC starts * AVRCP Spec 1.4 section 22.19 */ diff --git a/stack/avrc/avrc_pars_ct.cc b/stack/avrc/avrc_pars_ct.cc index 8a13a7326..40667e317 100644 --- a/stack/avrc/avrc_pars_ct.cc +++ b/stack/avrc/avrc_pars_ct.cc @@ -196,6 +196,11 @@ static tAVRC_STS avrc_pars_browse_rsp(tAVRC_MSG_BROWSE *p_msg, tAVRC_RESPONSE *p __func__, get_item_rsp->pdu, get_item_rsp->status, pkt_len, get_item_rsp->uid_counter, get_item_rsp->item_count); + if (get_item_rsp->status != AVRC_STS_NO_ERROR) { + AVRC_TRACE_WARNING("%s returning error %d", __func__, get_item_rsp->status); + return get_item_rsp->status; + } + /* get each of the items */ get_item_rsp->p_item_list = (tAVRC_ITEM *) osi_malloc (get_item_rsp->item_count * (sizeof(tAVRC_ITEM))); -- 2.11.0