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

Commit 8fa32c2c authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

Merge "Ensure that UHID_SET_REPORT procedure is concluded when invoked for...

Merge "Ensure that UHID_SET_REPORT procedure is concluded when invoked for HOGP device" am: 0ff06ae8 am: 6a8a1eb3

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2064388



Change-Id: Icf5b637ac5226c2bfd87e9f6a0033b348748c15c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f3a372d2 6a8a1eb3
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -603,14 +603,19 @@ void bta_hh_co_set_rpt_rsp(uint8_t dev_handle, uint8_t status) {


  // Send the HID set report reply to the kernel.
  // Send the HID set report reply to the kernel.
  if (p_dev->fd >= 0) {
  if (p_dev->fd >= 0) {
    struct uhid_event ev = {};
    uint32_t* set_rpt_id =
    uint32_t* set_rpt_id =
        (uint32_t*)fixed_queue_dequeue(p_dev->set_rpt_id_queue);
        (uint32_t*)fixed_queue_dequeue(p_dev->set_rpt_id_queue);
    if (set_rpt_id) {
      struct uhid_event ev = {};

      ev.type = UHID_SET_REPORT_REPLY;
      ev.type = UHID_SET_REPORT_REPLY;
      ev.u.set_report_reply.id = *set_rpt_id;
      ev.u.set_report_reply.id = *set_rpt_id;
      ev.u.set_report_reply.err = status;
      ev.u.set_report_reply.err = status;
      osi_free(set_rpt_id);
      osi_free(set_rpt_id);
      uhid_write(p_dev->fd, &ev);
      uhid_write(p_dev->fd, &ev);
    } else {
      LOG_VERBOSE("No pending UHID_SET_REPORT");
    }
  }
  }
#else
#else
  LOG_ERROR("Error: UHID_SET_REPORT_REPLY not supported");
  LOG_ERROR("Error: UHID_SET_REPORT_REPLY not supported");
+1 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,7 @@ typedef struct {
  bthh_connection_state_t dev_status;
  bthh_connection_state_t dev_status;
  uint8_t dev_handle;
  uint8_t dev_handle;
  RawAddress bd_addr;
  RawAddress bd_addr;
  bool le_hid;
  tBTA_HH_ATTR_MASK attr_mask;
  tBTA_HH_ATTR_MASK attr_mask;
  uint8_t sub_class;
  uint8_t sub_class;
  uint8_t app_id;
  uint8_t app_id;
+17 −2
Original line number Original line Diff line number Diff line
@@ -29,8 +29,11 @@


#include "btif/include/btif_hh.h"
#include "btif/include/btif_hh.h"


#include <base/logging.h>

#include <cstdint>
#include <cstdint>


#include "bta_hh_co.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_storage.h"
#include "btif/include/btif_storage.h"
#include "btif/include/btif_util.h"
#include "btif/include/btif_util.h"
@@ -43,8 +46,6 @@
#include "stack/include/l2c_api.h"
#include "stack/include/l2c_api.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


#include <base/logging.h>

#define COD_HID_KEYBOARD 0x0540
#define COD_HID_KEYBOARD 0x0540
#define COD_HID_POINTING 0x0580
#define COD_HID_POINTING 0x0580
#define COD_HID_COMBO 0x05C0
#define COD_HID_COMBO 0x05C0
@@ -796,6 +797,7 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
          BTIF_TRACE_WARNING(
          BTIF_TRACE_WARNING(
              "BTA_HH_OPEN_EVT: Error, failed to find the uhid driver...");
              "BTA_HH_OPEN_EVT: Error, failed to find the uhid driver...");
          p_dev->bd_addr = p_data->conn.bda;
          p_dev->bd_addr = p_data->conn.bda;
          p_dev->le_hid = p_data->conn.le_hid;
          // remove the connection  and then try again to reconnect from the
          // remove the connection  and then try again to reconnect from the
          // mouse side to recover
          // mouse side to recover
          btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_DISCONNECTED;
          btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_DISCONNECTED;
@@ -806,6 +808,7 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
              "... %d",
              "... %d",
              p_data->conn.handle);
              p_data->conn.handle);
          p_dev->bd_addr = p_data->conn.bda;
          p_dev->bd_addr = p_data->conn.bda;
          p_dev->le_hid = p_data->conn.le_hid;
          btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_CONNECTED;
          btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_CONNECTED;
          // Send set_idle if the peer_device is a keyboard
          // Send set_idle if the peer_device is a keyboard
          if (check_cod(&p_data->conn.bda, COD_HID_KEYBOARD) ||
          if (check_cod(&p_data->conn.bda, COD_HID_KEYBOARD) ||
@@ -900,6 +903,18 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
      if (p_dev != NULL) {
      if (p_dev != NULL) {
        HAL_CBACK(bt_hh_callbacks, handshake_cb, (RawAddress*)&(p_dev->bd_addr),
        HAL_CBACK(bt_hh_callbacks, handshake_cb, (RawAddress*)&(p_dev->bd_addr),
                  (bthh_status_t)p_data->hs_data.status);
                  (bthh_status_t)p_data->hs_data.status);

#ifdef OS_ANDROID  // Host kernel does not support UHID_SET_REPORT
        if (p_dev->le_hid && p_dev->set_rpt_id_queue) {
          /* There is no handshake response for HOGP. Conclude the
           * UHID_SET_REPORT procedure here. */
          uint32_t* set_rpt_id =
              (uint32_t*)fixed_queue_try_peek_first(p_dev->set_rpt_id_queue);
          if (set_rpt_id) {
            bta_hh_co_set_rpt_rsp(p_dev->dev_handle, p_data->dev_status.status);
          }
        }
#endif
      }
      }
      break;
      break;