summaryrefslogtreecommitdiffstats
path: root/btif/src/btif_hh.c
diff options
context:
space:
mode:
authorMike J. Chen <mjchen@google.com>2014-02-25 10:16:30 -0800
committerMike J. Chen <mjchen@google.com>2014-03-04 17:20:10 -0800
commitf691897800e086b6caf238ee78d560526e69c67d (patch)
tree7b8d5feae3f75db292a68db2b20bba043250123f /btif/src/btif_hh.c
parentbe6d58f35e66b9e57cf4978be68840cbc8ac2fc9 (diff)
downloadandroid_system_bt-f691897800e086b6caf238ee78d560526e69c67d.tar.gz
android_system_bt-f691897800e086b6caf238ee78d560526e69c67d.tar.bz2
android_system_bt-f691897800e086b6caf238ee78d560526e69c67d.zip
Add HID handshake_callback
It is called when the equivalent pkt is received from the HID client as a normal response to set_report() and set_protocol_mode(), and for errors for get_report() and get_protocol_mode(). Change-Id: I26ec37348e597f294f83907bbd256c88db5ac2ef Signed-off-by: Mike J. Chen <mjchen@google.com>
Diffstat (limited to 'btif/src/btif_hh.c')
-rw-r--r--btif/src/btif_hh.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index c3c1deed9..34b119d31 100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
@@ -868,16 +868,20 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
BTIF_TRACE_DEBUG2("BTA_HH_GET_RPT_EVT: status = %d, handle = %d",
p_data->hs_data.status, p_data->hs_data.handle);
- /* p_rpt_data in HANDSHAKE response case */
- if (hdr) {
- data = (UINT8 *)(hdr + 1) + hdr->offset;
- len = hdr->len;
- }
p_dev = btif_hh_find_connected_dev_by_handle(p_data->hs_data.handle);
if (p_dev) {
- HAL_CBACK(bt_hh_callbacks, get_report_cb,
- (bt_bdaddr_t*) &(p_dev->bd_addr),
- (bthh_status_t) p_data->hs_data.status, data, len);
+ /* p_rpt_data is NULL in HANDSHAKE response case */
+ if (hdr) {
+ data = (UINT8 *)(hdr + 1) + hdr->offset;
+ len = hdr->len;
+ HAL_CBACK(bt_hh_callbacks, get_report_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status, data, len);
+ } else {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status);
+ }
} else {
BTIF_TRACE_WARNING1("Error: cannot find device with handle %d", p_data->hs_data.handle);
}
@@ -886,6 +890,12 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
case BTA_HH_SET_RPT_EVT:
BTIF_TRACE_DEBUG2("BTA_HH_SET_RPT_EVT: status = %d, handle = %d",
p_data->dev_status.status, p_data->dev_status.handle);
+ p_dev = btif_hh_find_connected_dev_by_handle(p_data->dev_status.handle);
+ if (p_dev != NULL) {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t) p_data->hs_data.status);
+ }
break;
case BTA_HH_GET_PROTO_EVT:
@@ -895,13 +905,27 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
p_data->hs_data.rsp_data.proto_mode,
(p_data->hs_data.rsp_data.proto_mode == BTA_HH_PROTO_RPT_MODE) ? "Report Mode" :
(p_data->hs_data.rsp_data.proto_mode == BTA_HH_PROTO_BOOT_MODE) ? "Boot Mode" : "Unsupported");
- HAL_CBACK(bt_hh_callbacks, protocol_mode_cb,(bt_bdaddr_t*) &(p_dev->bd_addr), (bthh_status_t)p_data->hs_data.status,
- (bthh_protocol_mode_t) p_data->hs_data.rsp_data.proto_mode);
+ if (p_data->hs_data.rsp_data.proto_mode != BTA_HH_PROTO_UNKNOWN) {
+ HAL_CBACK(bt_hh_callbacks, protocol_mode_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status,
+ (bthh_protocol_mode_t) p_data->hs_data.rsp_data.proto_mode);
+ } else {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*) &(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status);
+ }
break;
case BTA_HH_SET_PROTO_EVT:
BTIF_TRACE_DEBUG2("BTA_HH_SET_PROTO_EVT: status = %d, handle = %d",
p_data->dev_status.status, p_data->dev_status.handle);
+ p_dev = btif_hh_find_connected_dev_by_handle(p_data->dev_status.handle);
+ if (p_dev) {
+ HAL_CBACK(bt_hh_callbacks, handshake_cb,
+ (bt_bdaddr_t*)&(p_dev->bd_addr),
+ (bthh_status_t)p_data->hs_data.status);
+ }
break;
case BTA_HH_GET_IDLE_EVT:
@@ -1617,7 +1641,7 @@ static bt_status_t set_report (bt_bdaddr_t *bd_addr, bthh_report_type_t reportTy
memset(hexbuf, 0, 200);
//TODO
hex_bytes_filled = ascii_2_hex(report, len, hexbuf);
- ALOGI("Hex bytes filled, hex value: %d", hex_bytes_filled);
+ BTIF_TRACE_DEBUG1("Hex bytes filled, hex value: %d", hex_bytes_filled);
if (hex_bytes_filled) {
BT_HDR* p_buf = create_pbuf(hex_bytes_filled, hexbuf);
if (p_buf == NULL) {