static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr) { bdstr_t bdstr; BTIF_TRACE_EVENT("%s: remote_addr=%s", __FUNCTION__, bd2str(bd_addr, &bdstr)); BTA_MceGetRemoteMasInstances(bd_addr->address); return BT_STATUS_SUCCESS; }
BOOLEAN btif_get_device_type(BD_ADDR bd_addr, int *addr_type, int *device_type) { if (device_type == NULL || addr_type == NULL) return FALSE; bt_bdaddr_t bda; bdcpy(bda.address, bd_addr); char bd_addr_str[18] = {0}; bd2str(&bda, &bd_addr_str); if (!btif_config_get_int("Remote", bd_addr_str, "DevType", device_type)) return FALSE; if (!btif_config_get_int("Remote", bd_addr_str, "AddrType", addr_type)) return FALSE; ALOGD("%s: Device [%s] type %d, addr. type %d", __FUNCTION__, bd_addr_str, *device_type, *addr_type); return TRUE; }
static void bta_pan_callback_transfer(UINT16 event, char *p_param) { tBTA_PAN *p_data = (tBTA_PAN *)p_param; switch(event) { case BTA_PAN_ENABLE_EVT: BTIF_TRACE_DEBUG0("BTA_PAN_ENABLE_EVT"); break; case BTA_PAN_SET_ROLE_EVT: { int btpan_role = bta_role_to_btpan(p_data->set_role.role); bt_status_t status = p_data->set_role.status == BTA_PAN_SUCCESS ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; btpan_control_state_t state = btpan_role == 0 ? BTPAN_STATE_DISABLED : BTPAN_STATE_ENABLED; callback.control_state_cb(state, btpan_role, status, TAP_IF_NAME); break; } case BTA_PAN_OPENING_EVT: { btpan_conn_t* conn; bdstr_t bds; bd2str((bt_bdaddr_t*)p_data->opening.bd_addr, &bds); BTIF_TRACE_DEBUG2("BTA_PAN_OPENING_EVT handle %d, addr: %s", p_data->opening.handle, bds); conn = btpan_find_conn_addr(p_data->opening.bd_addr); asrt(conn != NULL); if (conn) { conn->handle = p_data->opening.handle; int btpan_conn_local_role = bta_role_to_btpan(conn->local_role); int btpan_remote_role = bta_role_to_btpan(conn->remote_role); callback.connection_state_cb(BTPAN_STATE_CONNECTING, BT_STATUS_SUCCESS, (const bt_bdaddr_t*)p_data->opening.bd_addr, btpan_conn_local_role, btpan_remote_role); } else BTIF_TRACE_ERROR0("connection not found"); break; } case BTA_PAN_OPEN_EVT: { /* debug("BTA_PAN_OPEN_EVT, open status:%d, bd_addr = [%02X:%02X:%02X:%02X:%02X:%02X]", */ /* p_data->open.status, */ /* p_data->open.bd_addr[0], p_data->open.bd_addr[1], p_data->open.bd_addr[2], */ /* p_data->open.bd_addr[3], p_data->open.bd_addr[4], p_data->open.bd_addr[5]); */ btpan_connection_state_t state; bt_status_t status; btpan_conn_t* conn = btpan_find_conn_handle(p_data->open.handle); ALOGI("%s: event = BTA_PAN_OPEN_EVT p_data->open.status %d", __FUNCTION__, p_data->open.status); if(p_data->open.status == BTA_PAN_SUCCESS) { state = BTPAN_STATE_CONNECTED; status = BT_STATUS_SUCCESS; } else { state = BTPAN_STATE_DISCONNECTED; status = BT_STATUS_FAIL; btpan_cleanup_conn(conn); } /* debug("BTA_PAN_OPEN_EVT handle:%d, conn:%p", p_data->open.handle, conn); */ /* debug("conn bta local_role:%d, bta remote role:%d", conn->local_role, conn->remote_role); */ int btpan_conn_local_role = bta_role_to_btpan(p_data->open.local_role); /* debug("bta local_role:%d, bta remote role:%d", p_data->open.local_role, p_data->open.peer_role); */ int btpan_remote_role = bta_role_to_btpan(p_data->open.peer_role); callback.connection_state_cb(state, status, (const bt_bdaddr_t*)p_data->open.bd_addr, btpan_conn_local_role, btpan_remote_role); break; } case BTA_PAN_CLOSE_EVT: { btpan_conn_t* conn = btpan_find_conn_handle(p_data->close.handle); ALOGI("%s: event = BTA_PAN_CLOSE_EVT handle %d", __FUNCTION__, p_data->close.handle); btpan_close_conn(conn); if(conn && conn->handle >= 0) { /* debug("BTA_PAN_CLOSE_EVT, conn local_role:%d, remote_role:%d", conn->local_role, conn->remote_role); */ int btpan_conn_local_role = bta_role_to_btpan(conn->local_role); int btpan_remote_role = bta_role_to_btpan(conn->remote_role); callback.connection_state_cb(BTPAN_STATE_DISCONNECTED, 0, (const bt_bdaddr_t*)conn->peer, btpan_conn_local_role, btpan_remote_role); btpan_cleanup_conn(conn); } else BTIF_TRACE_ERROR1("pan handle not found (%d)", p_data->close.handle); break; } default: BTIF_TRACE_WARNING1("Unknown pan event %d", event); break; } }
/******************************************************************************* ** ** Function btif_hf_client_upstreams_evt ** ** Description Executes HF CLIENT UPSTREAMS events in btif context ** ** Returns void ** *******************************************************************************/ static void btif_hf_client_upstreams_evt(UINT16 event, char* p_param) { tBTA_HF_CLIENT *p_data = (tBTA_HF_CLIENT *)p_param; bdstr_t bdstr; BTIF_TRACE_DEBUG("%s: event=%s (%u)", __FUNCTION__, dump_hf_client_event(event), event); switch (event) { case BTA_HF_CLIENT_ENABLE_EVT: case BTA_HF_CLIENT_DISABLE_EVT: break; case BTA_HF_CLIENT_REGISTER_EVT: btif_hf_client_cb.handle = p_data->reg.handle; break; case BTA_HF_CLIENT_OPEN_EVT: if (p_data->open.status == BTA_HF_CLIENT_SUCCESS) { bdcpy(btif_hf_client_cb.connected_bda.address, p_data->open.bd_addr); btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_CONNECTED; btif_hf_client_cb.peer_feat = 0; btif_hf_client_cb.chld_feat = 0; //clear_phone_state(); } else if (btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_CONNECTING) { btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED; } else { BTIF_TRACE_WARNING("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s", __FUNCTION__, p_data->open.status, btif_hf_client_cb.state, bd2str(&btif_hf_client_cb.connected_bda, &bdstr)); break; } HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state, 0, 0, &btif_hf_client_cb.connected_bda); if (btif_hf_client_cb.state == BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED) bdsetany(btif_hf_client_cb.connected_bda.address); if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) btif_queue_advance(); break; case BTA_HF_CLIENT_CONN_EVT: btif_hf_client_cb.peer_feat = p_data->conn.peer_feat; btif_hf_client_cb.chld_feat = p_data->conn.chld_feat; btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED; HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state, btif_hf_client_cb.peer_feat, btif_hf_client_cb.chld_feat, &btif_hf_client_cb.connected_bda); /* Inform the application about in-band ringtone */ if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND) { HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED); } btif_queue_advance(); break; case BTA_HF_CLIENT_CLOSE_EVT: btif_hf_client_cb.state = BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED; HAL_CBACK(bt_hf_client_callbacks, connection_state_cb, btif_hf_client_cb.state, 0, 0, &btif_hf_client_cb.connected_bda); bdsetany(btif_hf_client_cb.connected_bda.address); btif_hf_client_cb.peer_feat = 0; btif_hf_client_cb.chld_feat = 0; btif_queue_advance(); break; case BTA_HF_CLIENT_IND_EVT: process_ind_evt(&p_data->ind); break; case BTA_HF_CLIENT_MIC_EVT: HAL_CBACK(bt_hf_client_callbacks, volume_change_cb, BTHF_CLIENT_VOLUME_TYPE_MIC, p_data->val.value); break; case BTA_HF_CLIENT_SPK_EVT: HAL_CBACK(bt_hf_client_callbacks, volume_change_cb, BTHF_CLIENT_VOLUME_TYPE_SPK, p_data->val.value); break; case BTA_HF_CLIENT_VOICE_REC_EVT: HAL_CBACK(bt_hf_client_callbacks, vr_cmd_cb, p_data->val.value); break; case BTA_HF_CLIENT_OPERATOR_NAME_EVT: HAL_CBACK(bt_hf_client_callbacks, current_operator_cb, p_data->operator.name); break; case BTA_HF_CLIENT_CLIP_EVT: HAL_CBACK(bt_hf_client_callbacks, clip_cb, p_data->number.number); break; case BTA_HF_CLIENT_BINP_EVT: HAL_CBACK(bt_hf_client_callbacks, last_voice_tag_number_callback, p_data->number.number); break; case BTA_HF_CLIENT_CCWA_EVT: HAL_CBACK(bt_hf_client_callbacks, call_waiting_cb, p_data->number.number); break; case BTA_HF_CLIENT_AT_RESULT_EVT: HAL_CBACK(bt_hf_client_callbacks, cmd_complete_cb, p_data->result.type, p_data->result.cme); break; case BTA_HF_CLIENT_CLCC_EVT: HAL_CBACK(bt_hf_client_callbacks, current_calls_cb, p_data->clcc.idx, p_data->clcc.inc ? BTHF_CLIENT_CALL_DIRECTION_INCOMING : BTHF_CLIENT_CALL_DIRECTION_OUTGOING, p_data->clcc.status, p_data->clcc.mpty ? BTHF_CLIENT_CALL_MPTY_TYPE_MULTI : BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE, p_data->clcc.number_present ? p_data->clcc.number : NULL); break; case BTA_HF_CLIENT_CNUM_EVT: if (p_data->cnum.service == 4) { HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_VOICE); } else if (p_data->cnum.service == 5) { HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_FAX); } else { HAL_CBACK(bt_hf_client_callbacks, subscriber_info_cb, p_data->cnum.number, BTHF_CLIENT_SERVICE_UNKNOWN); } break; case BTA_HF_CLIENT_BTRH_EVT: if (p_data->val.value <= BTRH_CLIENT_RESP_AND_HOLD_REJECT) { HAL_CBACK(bt_hf_client_callbacks, resp_and_hold_cb, p_data->val.value); } break; case BTA_HF_CLIENT_BSIR_EVT: if (p_data->val.value != 0) { HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED); } else { HAL_CBACK(bt_hf_client_callbacks, in_band_ring_tone_cb, BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED); } break; case BTA_HF_CLIENT_AUDIO_OPEN_EVT: HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_CONNECTED, &btif_hf_client_cb.connected_bda); break; case BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT: HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, &btif_hf_client_cb.connected_bda); break; case BTA_HF_CLIENT_AUDIO_CLOSE_EVT: HAL_CBACK(bt_hf_client_callbacks, audio_state_cb, BTHF_CLIENT_AUDIO_STATE_DISCONNECTED, &btif_hf_client_cb.connected_bda); break; case BTA_HF_CLIENT_RING_INDICATION: HAL_CBACK(bt_hf_client_callbacks, ring_indication_cb); break; default: BTIF_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event); break; } }
/******************************************************************************* ** ** Function btif_hf_upstreams_evt ** ** Description Executes HF UPSTREAMS events in btif context ** ** Returns void ** *******************************************************************************/ static void btif_hf_upstreams_evt(UINT16 event, char* p_param) { tBTA_AG *p_data = (tBTA_AG *)p_param; bdstr_t bdstr; BTIF_TRACE_DEBUG2("%s: event=%s", __FUNCTION__, dump_hf_event(event)); switch (event) { case BTA_AG_ENABLE_EVT: case BTA_AG_DISABLE_EVT: break; case BTA_AG_REGISTER_EVT: btif_hf_cb.handle = p_data->reg.hdr.handle; break; case BTA_AG_OPEN_EVT: if (p_data->open.status == BTA_AG_SUCCESS) { bdcpy(btif_hf_cb.connected_bda.address, p_data->open.bd_addr); btif_hf_cb.state = BTHF_CONNECTION_STATE_CONNECTED; btif_hf_cb.peer_feat = 0; clear_phone_state(); } else if (btif_hf_cb.state == BTHF_CONNECTION_STATE_CONNECTING) { btif_hf_cb.state = BTHF_CONNECTION_STATE_DISCONNECTED; } else { BTIF_TRACE_WARNING4("%s: AG open failed, but another device connected. status=%d state=%d connected device=%s", __FUNCTION__, p_data->open.status, btif_hf_cb.state, bd2str(&btif_hf_cb.connected_bda, &bdstr)); break; } HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda); if (btif_hf_cb.state == BTHF_CONNECTION_STATE_DISCONNECTED) bdsetany(btif_hf_cb.connected_bda.address); if (p_data->open.status != BTA_AG_SUCCESS) btif_queue_advance(); break; case BTA_AG_CLOSE_EVT: btif_hf_cb.state = BTHF_CONNECTION_STATE_DISCONNECTED; HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda); bdsetany(btif_hf_cb.connected_bda.address); btif_hf_cb.peer_feat = 0; clear_phone_state(); /* If AG_OPEN was received but SLC was not setup in a specified time (10 seconds), ** then AG_CLOSE may be received. We need to advance the queue here */ btif_queue_advance(); break; case BTA_AG_CONN_EVT: btif_hf_cb.peer_feat = p_data->conn.peer_feat; btif_hf_cb.state = BTHF_CONNECTION_STATE_SLC_CONNECTED; HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda); btif_queue_advance(); break; case BTA_AG_AUDIO_OPEN_EVT: HAL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_CONNECTED, &btif_hf_cb.connected_bda); break; case BTA_AG_AUDIO_CLOSE_EVT: HAL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_DISCONNECTED, &btif_hf_cb.connected_bda); break; /* BTA auto-responds, silently discard */ case BTA_AG_SPK_EVT: case BTA_AG_MIC_EVT: HAL_CBACK(bt_hf_callbacks, volume_cmd_cb, (event == BTA_AG_SPK_EVT) ? BTHF_VOLUME_TYPE_SPK : BTHF_VOLUME_TYPE_MIC, p_data->val.num); break; case BTA_AG_AT_A_EVT: HAL_CBACK(bt_hf_callbacks, answer_call_cmd_cb); break; /* Java needs to send OK/ERROR for these commands */ case BTA_AG_AT_BLDN_EVT: case BTA_AG_AT_D_EVT: HAL_CBACK(bt_hf_callbacks, dial_call_cmd_cb, (event == BTA_AG_AT_D_EVT) ? p_data->val.str : NULL); break; case BTA_AG_AT_CHUP_EVT: HAL_CBACK(bt_hf_callbacks, hangup_call_cmd_cb); break; case BTA_AG_AT_CIND_EVT: HAL_CBACK(bt_hf_callbacks, cind_cmd_cb); break; case BTA_AG_AT_VTS_EVT: HAL_CBACK(bt_hf_callbacks, dtmf_cmd_cb, p_data->val.str[0]); break; case BTA_AG_AT_BVRA_EVT: HAL_CBACK(bt_hf_callbacks, vr_cmd_cb, (p_data->val.num == 1) ? BTHF_VR_STATE_STARTED : BTHF_VR_STATE_STOPPED); break; case BTA_AG_AT_NREC_EVT: HAL_CBACK(bt_hf_callbacks, nrec_cmd_cb, (p_data->val.num == 1) ? BTHF_NREC_START : BTHF_NREC_STOP); break; /* TODO: Add a callback for CBC */ case BTA_AG_AT_CBC_EVT: break; case BTA_AG_AT_CKPD_EVT: HAL_CBACK(bt_hf_callbacks, key_pressed_cmd_cb); break; /* Java needs to send OK/ERROR for these commands */ case BTA_AG_AT_CHLD_EVT: HAL_CBACK(bt_hf_callbacks, chld_cmd_cb, atoi(p_data->val.str)); break; case BTA_AG_AT_CLCC_EVT: HAL_CBACK(bt_hf_callbacks, clcc_cmd_cb, p_data->val.num); break; case BTA_AG_AT_COPS_EVT: HAL_CBACK(bt_hf_callbacks, cops_cmd_cb); break; case BTA_AG_AT_UNAT_EVT: HAL_CBACK(bt_hf_callbacks, unknown_at_cmd_cb, p_data->val.str); break; case BTA_AG_AT_CNUM_EVT: HAL_CBACK(bt_hf_callbacks, cnum_cmd_cb); break; /* TODO: Some of these commands may need to be sent to app. For now respond with error */ case BTA_AG_AT_BINP_EVT: case BTA_AG_AT_BTRH_EVT: send_at_result(BTA_AG_OK_ERROR, BTA_AG_ERR_OP_NOT_SUPPORTED); break; default: BTIF_TRACE_WARNING2("%s: Unhandled event: %d", __FUNCTION__, event); break; } }