X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=btif%2Fsrc%2Fbtif_rc.c;h=9bc57fd61fbb76f7c5b13912792b072aa2c826e5;hb=2d7ddd09c163c84eacddd101cf08fd8021a35370;hp=1eaff9f8de14b361d5862918c7aaaae60f209d7e;hpb=90b71eac9b45f90ff3267fa0a400cc1daaec88d4;p=android-x86%2Fsystem-bt.git diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c index 1eaff9f8d..9bc57fd61 100644 --- a/btif/src/btif_rc.c +++ b/btif/src/btif_rc.c @@ -34,15 +34,6 @@ #include #include -/** - * TODO(eisenbach): cutils/properties.h is only being used to pull-in runtime - * settings on Android. Remove this conditional include once we have a generic - * way to obtain system properties. - */ -#if !defined(OS_GENERIC) -#include -#endif /* !defined(OS_GENERIC) */ - #include "avrc_defs.h" #include "bta_api.h" #include "bta_av_api.h" @@ -52,9 +43,12 @@ #include "bt_common.h" #include "device/include/interop.h" #include "uinput.h" +#include "bdaddr.h" #include "osi/include/list.h" +#include "osi/include/properties.h" #include "btu.h" #define RC_INVALID_TRACK_ID (0xFFFFFFFFFFFFFFFFULL) + /***************************************************************************** ** Constants & Macros ******************************************************************************/ @@ -240,21 +234,23 @@ static void send_reject_response (UINT8 rc_handle, UINT8 label, static UINT8 opcode_from_pdu(UINT8 pdu); static void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, tBTA_AV_CODE code, tAVRC_RESPONSE *pmetamsg_resp); +#if (AVRC_ADV_CTRL_INCLUDED == TRUE) static void register_volumechange(UINT8 label); +#endif static void lbl_init(); static void lbl_destroy(); static void init_all_transactions(); static bt_status_t get_transaction(rc_transaction_t **ptransaction); static void release_transaction(UINT8 label); static rc_transaction_t* get_transaction_by_lbl(UINT8 label); +#if (AVRC_ADV_CTRL_INCLUDED == TRUE) static void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); +#endif #if (AVRC_CTLR_INCLUDED == TRUE) static void handle_avk_rc_metamsg_cmd(tBTA_AV_META_MSG *pmeta_msg); static void handle_avk_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg); static void btif_rc_ctrl_upstreams_rsp_cmd( UINT8 event, tAVRC_COMMAND *pavrc_cmd, UINT8 label); -static void btif_rc_ctrl_upstreams_rsp_evt( - UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8* p_buf, UINT16 buf_len, UINT8 rsp_type); static void rc_ctrl_procedure_complete(); static void rc_stop_play_status_timer(); static void register_for_event_notification (btif_rc_supported_event_t *p_event); @@ -278,7 +274,9 @@ static bt_status_t list_player_app_setting_value_cmd(uint8_t attrib_id); static bt_status_t get_player_app_setting_cmd(uint8_t num_attrib, uint8_t* attrib_ids); #endif static void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND* p_param, UINT8 ctype, UINT8 label); +#if (AVRC_ADV_CTRL_INCLUDED == TRUE) static void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label); +#endif static void rc_start_play_status_timer(void); static bool absolute_volume_disabled(void); @@ -469,10 +467,18 @@ void handle_rc_features(BD_ADDR bd_addr) { btrc_remote_features_t rc_features = BTRC_FEAT_NONE; bt_bdaddr_t rc_addr; + bdcpy(rc_addr.address, btif_rc_cb.rc_addr); + bt_bdaddr_t avdtp_addr = btif_av_get_addr(); - if (interop_match(INTEROP_DISABLE_ABSOLUTE_VOLUME, &rc_addr) - || absolute_volume_disabled()) + bdstr_t addr1, addr2; + BTIF_TRACE_DEBUG("%s: AVDTP Address: %s AVCTP address: %s", __func__, + bdaddr_to_string(&avdtp_addr, addr1, sizeof(addr1)), + bdaddr_to_string(&rc_addr, addr2, sizeof(addr2))); + + if (interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &rc_addr) + || absolute_volume_disabled() + || bdcmp(avdtp_addr.address, rc_addr.address)) btif_rc_cb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL; if (btif_rc_cb.rc_features & BTA_AV_FEAT_BROWSE) @@ -731,22 +737,6 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd) pressed = 1; } - /* If this is Play/Pause command (press or release) before processing, check the following - * a voice call has ended recently - * the remote device is not of type headset - * If the above conditions meet, drop the Play/Pause command - * This fix is to interop with certain carkits which sends an automatic PLAY or PAUSE - * commands right after call ends - */ - if ((p_remote_cmd->rc_id == BTA_AV_RC_PLAY || p_remote_cmd->rc_id == BTA_AV_RC_PAUSE)&& - (btif_hf_call_terminated_recently() == TRUE) && - (check_cod( (const bt_bdaddr_t*)&(btif_rc_cb.rc_addr), COD_AV_HEADSETS) != TRUE)) - { - BTIF_TRACE_DEBUG("%s:Dropping the play/Pause command received right after call end cmd:%d", - __FUNCTION__,p_remote_cmd->rc_id); - return; - } - if (p_remote_cmd->rc_id == BTA_AV_RC_FAST_FOR || p_remote_cmd->rc_id == BTA_AV_RC_REWIND) { HAL_CBACK(bt_rc_callbacks, passthrough_cmd_cb, p_remote_cmd->rc_id, pressed); return; @@ -1515,6 +1505,7 @@ static void btif_rc_ctrl_upstreams_rsp_cmd(UINT8 event, tAVRC_COMMAND *pavrc_cmd } #endif +#if (AVRC_ADV_CTRL_INCLUDED == TRUE) /******************************************************************************* ** ** Function btif_rc_upstreams_rsp_evt @@ -1529,7 +1520,6 @@ static void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, BTIF_TRACE_EVENT("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, dump_rc_pdu(pavrc_resp->pdu), btif_rc_cb.rc_handle, ctype, label); -#if (AVRC_ADV_CTRL_INCLUDED == TRUE) switch (event) { case AVRC_PDU_REGISTER_NOTIFICATION: @@ -1553,8 +1543,8 @@ static void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, default: return; } -#endif } +#endif /************************************************************************************ ** AVRCP API Functions @@ -1827,6 +1817,7 @@ static bt_status_t set_volume(uint8_t volume) return status; } +#if (AVRC_ADV_CTRL_INCLUDED == TRUE) /*************************************************************************** ** ** Function register_volumechange @@ -1944,6 +1935,7 @@ static void handle_rc_metamsg_rsp(tBTA_AV_META_MSG *pmeta_msg) btif_rc_upstreams_rsp_evt((uint16_t)avrc_response.rsp.pdu, &avrc_response, pmeta_msg->code, pmeta_msg->label); } +#endif #if (AVRC_CTLR_INCLUDED == TRUE) /*************************************************************************** @@ -2708,7 +2700,7 @@ static void handle_app_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_LIST_APP } get_player_app_setting_cmd (p_app_settings->num_attrs, attrs); HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); } } else if (p_app_settings->ext_attr_index < p_app_settings->num_ext_attrs) @@ -2821,7 +2813,7 @@ static void handle_app_attr_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET attrs[xx] = p_app_settings->attrs[xx].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); get_player_app_setting_cmd (xx, attrs); return; @@ -2901,7 +2893,7 @@ static void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC attrs[xx] = p_app_settings->attrs[xx].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, 0, NULL); + p_app_settings->num_attrs, p_app_settings->attrs, 0, NULL); get_player_app_setting_cmd (xx, attrs); return; @@ -2947,8 +2939,8 @@ static void handle_app_attr_val_txt_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC attrs[xx+x] = p_app_settings->ext_attrs[x].attr_id; } HAL_CBACK (bt_rc_ctrl_callbacks, playerapplicationsetting_cb, &rc_addr, - p_app_settings->num_attrs, &p_app_settings->attrs, - p_app_settings->num_ext_attrs, &p_app_settings->ext_attrs); + p_app_settings->num_attrs, p_app_settings->attrs, + p_app_settings->num_ext_attrs, p_app_settings->ext_attrs); get_player_app_setting_cmd (xx + x, attrs); /* Free the application settings information after sending to @@ -3003,35 +2995,31 @@ static void handle_set_app_attr_val_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC ** Returns None ** ***************************************************************************/ -static void handle_get_elem_attr_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GET_ELEM_ATTRS_RSP *p_rsp) +static void handle_get_elem_attr_response (tBTA_AV_META_MSG *pmeta_msg, + tAVRC_GET_ELEM_ATTRS_RSP *p_rsp) { - btrc_element_attr_val_t *p_attr; - bt_bdaddr_t rc_addr; - UINT16 xx; + if (p_rsp->status == AVRC_STS_NO_ERROR) { + bt_bdaddr_t rc_addr; + size_t buf_size = p_rsp->num_attr * sizeof(btrc_element_attr_val_t); + btrc_element_attr_val_t *p_attr = + (btrc_element_attr_val_t *)osi_calloc(buf_size); - bdcpy(rc_addr.address, btif_rc_cb.rc_addr); + bdcpy(rc_addr.address, btif_rc_cb.rc_addr); - if (p_rsp->status == AVRC_STS_NO_ERROR) - { - size_t buf_size = p_rsp->num_attr * sizeof(btrc_element_attr_val_t); - p_attr = (btrc_element_attr_val_t *)osi_malloc(buf_size); - memset(p_attr, 0, buf_size); - for (xx = 0; xx < p_rsp->num_attr; xx++) { - p_attr[xx].attr_id = p_rsp->p_attrs[xx].attr_id; + for (int i = 0; i < p_rsp->num_attr; i++) { + p_attr[i].attr_id = p_rsp->p_attrs[i].attr_id; /* Todo. Legth limit check to include null */ - if (p_rsp->p_attrs[xx].name.str_len && - p_rsp->p_attrs[xx].name.p_str) { - memcpy(p_attr[xx].text, p_rsp->p_attrs[xx].name.p_str, - p_rsp->p_attrs[xx].name.str_len); - osi_free_and_reset((void **)&p_rsp->p_attrs[xx].name.p_str); + if (p_rsp->p_attrs[i].name.str_len && + p_rsp->p_attrs[i].name.p_str) { + memcpy(p_attr[i].text, p_rsp->p_attrs[i].name.p_str, + p_rsp->p_attrs[i].name.str_len); + osi_free_and_reset((void **)&p_rsp->p_attrs[i].name.p_str); } } HAL_CBACK(bt_rc_ctrl_callbacks, track_changed_cb, &rc_addr, p_rsp->num_attr, p_attr); osi_free(p_attr); - } - else if (p_rsp->status == BTIF_RC_STS_TIMEOUT) - { + } else if (p_rsp->status == BTIF_RC_STS_TIMEOUT) { /* Retry for timeout case, this covers error handling * for continuation failure also. */ @@ -3045,11 +3033,9 @@ static void handle_get_elem_attr_response (tBTA_AV_META_MSG *pmeta_msg, tAVRC_GE AVRC_MEDIA_ATTR_ID_PLAYING_TIME }; get_element_attribute_cmd (AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list); - } - else - { + } else { BTIF_TRACE_ERROR("%s: Error in get element attr procedure %d", - __FUNCTION__, p_rsp->status); + __func__, p_rsp->status); } } @@ -4253,13 +4239,11 @@ static void sleep_ms(period_ms_t timeout_ms) { } static bool absolute_volume_disabled() { -#if !defined(OS_GENERIC) char volume_disabled[PROPERTY_VALUE_MAX] = {0}; - property_get("persist.bluetooth.disableabsvol", volume_disabled, "false"); + osi_property_get("persist.bluetooth.disableabsvol", volume_disabled, "false"); if (strncmp(volume_disabled, "true", 4) == 0) { BTIF_TRACE_WARNING("%s: Absolute volume disabled by property", __func__); return true; } -#endif /* !defined(OS_GENERIC) */ return false; }