/******************************************************************************* ** ** Function cleanup ** ** Description Closes the HF interface ** ** Returns bt_status_t ** *******************************************************************************/ static void cleanup( void ) { BTIF_TRACE_EVENT1("%s", __FUNCTION__); if (bt_hf_callbacks) { btif_disable_service(BTA_HFP_SERVICE_ID); bt_hf_callbacks = NULL; } }
/******************************************************************************* ** ** Function btif_hf_init ** ** Description initializes the hf interface ** ** Returns bt_status_t ** *******************************************************************************/ static bt_status_t init( bthf_callbacks_t* callbacks ) { BTIF_TRACE_EVENT1("%s", __FUNCTION__); bt_hf_callbacks = callbacks; /* Invoke the enable service API to the core to set the appropriate service_id * Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone) * othwerwise only HSP is enabled (tablet) */ #if (defined(BTIF_HF_SERVICES) && (BTIF_HF_SERVICES & BTA_HFP_SERVICE_MASK)) btif_enable_service(BTA_HFP_SERVICE_ID); #else btif_enable_service(BTA_HSP_SERVICE_ID); #endif memset(&btif_hf_cb, 0, sizeof(btif_hf_cb_t)); clear_phone_state(); return BT_STATUS_SUCCESS; }
/*************************************************************************** * Function handle_rc_metamsg_cmd * * - Argument: tBTA_AV_VENDOR Structure containing the received * metamsg command * * - Description: Remote control metamsg command handler (AVRCP 1.3) * ***************************************************************************/ void handle_rc_metamsg_cmd (tBTA_AV_META_MSG *pmeta_msg) { /* Parse the metamsg command and pass it on to BTL-IFS */ UINT8 scratch_buf[512] = {0}; tAVRC_COMMAND avrc_command = {0}; tAVRC_STS status; int param_len; BTIF_TRACE_EVENT1("+ %s", __FUNCTION__); if (pmeta_msg->p_msg->hdr.opcode != AVRC_OP_VENDOR) { BTIF_TRACE_WARNING1("Invalid opcode: %x", pmeta_msg->p_msg->hdr.opcode); return; } if (pmeta_msg->len < 3) { BTIF_TRACE_WARNING2("Invalid length.Opcode: 0x%x, len: 0x%x", pmeta_msg->p_msg->hdr.opcode, pmeta_msg->len); return; } if (pmeta_msg->code >= AVRC_RSP_NOT_IMPL) { BTIF_TRACE_DEBUG3("%s:Received vendor dependent rsp. code: %d len: %d. Not processing it.", __FUNCTION__, pmeta_msg->code, pmeta_msg->len); return; } status = AVRC_ParsCommand(pmeta_msg->p_msg, &avrc_command, scratch_buf, sizeof(scratch_buf)); if (status != AVRC_STS_NO_ERROR) { /* return error */ BTIF_TRACE_WARNING2("%s: Error in parsing received metamsg command. status: 0x%02x", __FUNCTION__, status); send_reject_response(pmeta_msg->rc_handle, pmeta_msg->label, avrc_command.pdu, status); } else { /* if RegisterNotification, add it to our registered queue */ if (avrc_command.cmd.pdu == AVRC_PDU_REGISTER_NOTIFICATION) { UINT8 event_id = avrc_command.reg_notif.event_id; param_len = sizeof(tAVRC_REG_NOTIF_CMD); BTIF_TRACE_EVENT3("%s: New register notification received. event_id:%s, label:0x%x", __FUNCTION__, dump_rc_notification_event_id(event_id), pmeta_msg->label); btif_rc_cb.rc_notif[event_id-1].bNotify = TRUE; btif_rc_cb.rc_notif[event_id-1].label = pmeta_msg->label; if(event_id == AVRC_EVT_UIDS_CHANGE) { handle_uid_changed_notification(pmeta_msg, &avrc_command); return; } } BTIF_TRACE_EVENT2("%s: Passing received metamsg command to app. pdu: %s", __FUNCTION__, dump_rc_pdu(avrc_command.cmd.pdu)); /* Since handle_rc_metamsg_cmd() itself is called from *btif context, no context switching is required. Invoke * btif_rc_upstreams_evt directly from here. */ btif_rc_upstreams_evt((uint16_t)avrc_command.cmd.pdu, &avrc_command, pmeta_msg->code, pmeta_msg->label); } }
/******************************************************************************* ** ** Function btif_hf_get_interface ** ** Description Get the hf callback interface ** ** Returns bthf_interface_t ** *******************************************************************************/ const bthf_interface_t *btif_hf_get_interface() { BTIF_TRACE_EVENT1("%s", __FUNCTION__); return &bthfInterface; }