Merge branch 'bugfix/fix_some_bugs_in_bluedroid' into 'release/v5.4'

fix(bt/bluedroid): Fixed some avrcp cover art related bugs

See merge request espressif/esp-idf!35505
This commit is contained in:
Wang Meng Yang 2025-01-06 12:21:49 +08:00
commit 84053a42f4
6 changed files with 32 additions and 24 deletions

View File

@ -278,6 +278,7 @@ void bta_av_ca_api_get(tBTA_AV_RCB *p_rcb, tBTA_AV_DATA *p_data)
GOEPC_RequestAddHeader(p_rcb->cover_art_goep_hdl, COVER_ART_HEADER_ID_IMG_HANDLE, (UINT8 *)image_handle_utf16, BTA_AV_CA_IMG_HDL_UTF16_LEN);
if (p_data->api_ca_get.type == BTA_AV_CA_GET_IMAGE) {
GOEPC_RequestAddHeader(p_rcb->cover_art_goep_hdl, COVER_ART_HEADER_ID_IMG_DESCRIPTOR, (UINT8 *)p_data->api_ca_get.image_descriptor, p_data->api_ca_get.image_descriptor_len);
osi_free(p_data->api_ca_get.image_descriptor);
}
/* always request to enable srm */
GOEPC_RequestSetSRM(p_rcb->cover_art_goep_hdl, TRUE, FALSE);

View File

@ -359,7 +359,7 @@ UINT16 GOEPC_RequestAddHeader(UINT16 handle, UINT8 header_id, const UINT8 *data,
break;
}
if (data == NULL || data_len == 0) {
if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) {
ret = GOEP_INVALID_PARAM;
break;
}

View File

@ -8,11 +8,12 @@
#include "common/bt_target.h"
#define GOEP_SUCCESS 0 /* Operation successful */
#define GOEP_FAILURE 1 /* Operation failed */
#define GOEP_NO_RESOURCES 3 /* Not enough resources */
#define GOEP_BAD_HANDLE 4 /* Bad handle */
#define GOEP_INVALID_PARAM 5 /* Invalid parameter */
#define GOEP_INVALID_STATE 6 /* Operation not allow in current state */
#define GOEP_CONGEST 7 /* Congest */
#define GOEP_TL_ERROR 8 /* Lower transport layer error */
/* GOEP Client or Server(not supported yet) API return code */
#define GOEP_SUCCESS 0x00 /* Operation successful */
#define GOEP_FAILURE 0x01 /* Operation failed */
#define GOEP_NO_RESOURCES 0x02 /* Not enough resources */
#define GOEP_BAD_HANDLE 0x04 /* Bad handle */
#define GOEP_INVALID_PARAM 0x08 /* Invalid parameter */
#define GOEP_INVALID_STATE 0x10 /* Operation not allow in current state */
#define GOEP_CONGEST 0x20 /* Congest */
#define GOEP_TL_ERROR 0x40 /* Lower transport layer error */

View File

@ -24,10 +24,6 @@
#define OBEX_STATE_OPENING 1 /* Starting to open a connection */
#define OBEX_STATE_OPENED 2 /* Connection opened */
/* Store 16 bits data in big endian format, not modify the p_buf */
#define STORE16BE(p_buf, data) do { *p_buf = ((data)>>8)&0xff; \
*(p_buf+1) = (data)&0xff;} while(0)
/* OBEX Connection Control block */
typedef struct {
tOBEX_MSG_CBACK *callback; /* Connection msg callback function */

View File

@ -34,7 +34,7 @@ static inline void obex_server_to_tl_server(tOBEX_SVR_INFO *server, tOBEX_TL_SVR
static inline void obex_updata_packet_length(BT_HDR *p_buf, UINT16 len)
{
UINT8 *p_pkt_len = (UINT8 *)(p_buf + 1) + p_buf->offset + 1;
STORE16BE(p_pkt_len, len);
UINT16_TO_BE_FIELD(p_pkt_len, len);
}
/*******************************************************************************
@ -343,7 +343,7 @@ UINT16 OBEX_BuildRequest(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out_
/* byte 4: flags */
*p_data++ = info->flags;
/* byte 5, 6: maximum OBEX packet length, recommend to set as our mtu*/
STORE16BE(p_data, info->max_packet_length);
UINT16_TO_BE_FIELD(p_data, info->max_packet_length);
pkt_len += 4;
break;
case OBEX_OPCODE_SETPATH:
@ -357,7 +357,7 @@ UINT16 OBEX_BuildRequest(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out_
break;
}
STORE16BE(p_pkt_len, pkt_len);
UINT16_TO_BE_FIELD(p_pkt_len, pkt_len);
p_buf->len = pkt_len;
*out_pkt = p_buf;
return OBEX_SUCCESS;
@ -405,14 +405,14 @@ UINT16 OBEX_BuildResponse(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out
/* byte 4: flags */
*p_data++ = info->flags;
/* byte 5, 6: maximum OBEX packet length, recommend to set as our mtu */
STORE16BE(p_data, info->max_packet_length);
UINT16_TO_BE_FIELD(p_data, info->max_packet_length);
pkt_len += 4;
break;
default:
break;
}
STORE16BE(p_pkt_len, pkt_len);
UINT16_TO_BE_FIELD(p_pkt_len, pkt_len);
p_buf->len = pkt_len;
*out_pkt = p_buf;
return OBEX_SUCCESS;
@ -465,7 +465,7 @@ UINT16 OBEX_AppendHeader(BT_HDR *pkt, const UINT8 *header)
pkt->len += header_len;
/* point to packet len */
p_data++;
STORE16BE(p_data, pkt->len);
UINT16_TO_BE_FIELD(p_data, pkt->len);
return OBEX_SUCCESS;
}
@ -481,7 +481,11 @@ UINT16 OBEX_AppendHeader(BT_HDR *pkt, const UINT8 *header)
*******************************************************************************/
UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UINT16 data_len)
{
if (pkt == NULL || data == NULL) {
if (pkt == NULL) {
return OBEX_INVALID_PARAM;
}
if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) {
return OBEX_INVALID_PARAM;
}
@ -524,15 +528,17 @@ UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UIN
*p_start++ = header_id;
if (store_header_len) {
/* store header length */
STORE16BE(p_start, header_len);
UINT16_TO_BE_FIELD(p_start, header_len);
p_start+= 2;
}
/* store data */
memcpy(p_start, data, data_len);
if (data != NULL) {
/* store data */
memcpy(p_start, data, data_len);
}
pkt->len += header_len;
/* point to packet len */
p_data++;
STORE16BE(p_data, pkt->len);
UINT16_TO_BE_FIELD(p_data, pkt->len);
return OBEX_SUCCESS;
}

View File

@ -484,6 +484,10 @@ void obex_tl_l2cap_disconnect_ind(UINT16 lcid, BOOLEAN is_conf_needed)
return;
}
if (p_ccb->initiator && find_scb_by_psm(p_ccb->vpsm) == NULL) {
L2CA_Deregister(p_ccb->vpsm);
}
tOBEX_TL_MSG msg = {0};
msg.any.hdl = p_ccb->allocated;
obex_tl_l2cap_cb.callback(OBEX_TL_DIS_CONN_EVT, &msg);