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

Commit 72afff0f authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix random crashes in HID related code

Operation on characteristics/descriptors shouldn't access GATT database
when it's executed. This could happen while service rediscovery is in
progress.

Bug: 32240759
Test: connect to HID device
Change-Id: Ie2b6e6b451456204b1cea1e500df9a0ff949a9ef
parent b11d8133
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -166,31 +166,27 @@ static void gatt_execute_next_op(uint16_t conn_id) {
    gatt_operation &op = gatt_ops.front();
    gatt_operation &op = gatt_ops.front();


    if (op.type == GATT_READ_CHAR) {
    if (op.type == GATT_READ_CHAR) {
        const tBTA_GATTC_CHARACTERISTIC *p_char = BTA_GATTC_GetCharacteristic(conn_id, op.handle);
        act_read_cb = op.read_cb;
        act_read_cb = op.read_cb;
        act_read_cb_data = op.read_cb_data;
        act_read_cb_data = op.read_cb_data;
        BTA_GATTC_ReadCharacteristic(conn_id, p_char->handle, BTA_GATT_AUTH_REQ_NONE,
        BTA_GATTC_ReadCharacteristic(conn_id, op.handle, BTA_GATT_AUTH_REQ_NONE,
                                     gatt_read_op_finished, NULL);
                                     gatt_read_op_finished, NULL);


    } else if (op.type == GATT_READ_DESC) {
    } else if (op.type == GATT_READ_DESC) {
        const tBTA_GATTC_DESCRIPTOR *p_desc = BTA_GATTC_GetDescriptor(conn_id, op.handle);
        act_read_cb = op.read_cb;
        act_read_cb = op.read_cb;
        act_read_cb_data = op.read_cb_data;
        act_read_cb_data = op.read_cb_data;
        BTA_GATTC_ReadCharDescr(conn_id, p_desc->handle, BTA_GATT_AUTH_REQ_NONE,
        BTA_GATTC_ReadCharDescr(conn_id, op.handle, BTA_GATT_AUTH_REQ_NONE,
                                gatt_read_op_finished, NULL);
                                gatt_read_op_finished, NULL);


    } else if (op.type == GATT_WRITE_CHAR) {
    } else if (op.type == GATT_WRITE_CHAR) {
        const tBTA_GATTC_CHARACTERISTIC *p_char = BTA_GATTC_GetCharacteristic(conn_id, op.handle);
        act_write_cb = op.write_cb;
        act_write_cb = op.write_cb;
        act_write_cb_data = op.write_cb_data;
        act_write_cb_data = op.write_cb_data;
        BTA_GATTC_WriteCharValue(conn_id, p_char->handle, op.write_type, std::move(op.value),
        BTA_GATTC_WriteCharValue(conn_id, op.handle, op.write_type, std::move(op.value),
                                 BTA_GATT_AUTH_REQ_NONE, gatt_write_op_finished, NULL);
                                 BTA_GATT_AUTH_REQ_NONE, gatt_write_op_finished, NULL);


    } else if (op.type == GATT_WRITE_DESC) {
    } else if (op.type == GATT_WRITE_DESC) {
        const tBTA_GATTC_DESCRIPTOR *p_desc = BTA_GATTC_GetDescriptor(conn_id, op.handle);
        act_write_cb = op.write_cb;
        act_write_cb = op.write_cb;
        act_write_cb_data = op.write_cb_data;
        act_write_cb_data = op.write_cb_data;
        BTA_GATTC_WriteCharDescr(conn_id, p_desc->handle, std::move(op.value),
        BTA_GATTC_WriteCharDescr(conn_id, op.handle, std::move(op.value),
                                 BTA_GATT_AUTH_REQ_NONE, gatt_write_op_finished, NULL);
                                 BTA_GATT_AUTH_REQ_NONE, gatt_write_op_finished, NULL);
    }
    }