Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1b5105d authored by Mike J. Chen's avatar Mike J. Chen
Browse files

Fix HID get_report callback support



There were multiple bugs in the code for get_report event
callback handling:

1) the p_dev lookup was using the wrong argument so was coming
   up with NULL ptr and passing it through to the callback

2) the BT_HDR * was being passed to the callback instead of a
   ptr to the payload

3) the size was being passed as a constant BT_HDR_SIZE.

It looked like this code was expecting the callback to parse
the BT_HDR, but that's an internal bluedroid structure.
The callback is defined as receiving the report data and the
report data size, which this change now provides.

Note that the payload might be NULL if the device returns
a HANDSHAKE error msg instead, and so it is valid to pass
the callback a NULL payload ptr and a 0 size.

Change-Id: I462b5cb5d4c460af085dc6e15f59c778a020a80e
Signed-off-by: default avatarMike J. Chen <mjchen@google.com>
parent a451e1c6
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -878,14 +878,28 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
                BTIF_TRACE_WARNING1("Error: cannot find device with handle %d", p_data->dev_status.handle);
            }
            break;
        case BTA_HH_GET_RPT_EVT:
        case BTA_HH_GET_RPT_EVT: {
            BT_HDR *hdr = p_data->hs_data.rsp_data.p_rpt_data;
            UINT8 *data = NULL;
            UINT16 len = 0;

            BTIF_TRACE_DEBUG2("BTA_HH_GET_RPT_EVT: status = %d, handle = %d",
                 p_data->hs_data.status, p_data->hs_data.handle);
            p_dev = btif_hh_find_connected_dev_by_handle(p_data->conn.handle);
            HAL_CBACK(bt_hh_callbacks, get_report_cb,(bt_bdaddr_t*) &(p_dev->bd_addr), (bthh_status_t) p_data->hs_data.status,
                (uint8_t*) p_data->hs_data.rsp_data.p_rpt_data, BT_HDR_SIZE);
            /* 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);
            } else {
                BTIF_TRACE_WARNING1("Error: cannot find device with handle %d", p_data->hs_data.handle);
            }
            break;

        }
        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);
@@ -1477,6 +1491,7 @@ static bt_status_t get_protocol (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t prot

    p_dev = btif_hh_find_connected_dev_by_bda(bd_addr);
    if (p_dev != NULL) {

        BTA_HhGetProtoMode(p_dev->dev_handle);
    }
    else {