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

Commit 9a9c626e authored by Chris Manton's avatar Chris Manton
Browse files

Add polling thread pid to hid control block

Bug: 183374320
Test: gd/cert/run
Tag: #refactor

Change-Id: I7cc676cb9af62d9aac1297e44b4bc590aa3380f6
parent d56c4b76
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -229,7 +229,6 @@ static inline pthread_t create_thread(void* (*start_routine)(void*),
 ******************************************************************************/
static void* btif_hh_poll_event_thread(void* arg) {
  btif_hh_device_t* p_dev = (btif_hh_device_t*)arg;
  APPL_TRACE_DEBUG("%s: Thread created fd = %d", __func__, p_dev->fd);
  struct pollfd pfds[1];

  // This thread is created by bt_main_thread with RT priority. Lower the thread
@@ -241,7 +240,10 @@ static void* btif_hh_poll_event_thread(void* arg) {
    p_dev->hh_poll_thread_id = -1;
    return 0;
  }
  p_dev->pid = gettid();
  pthread_setname_np(pthread_self(), BT_HH_THREAD);
  LOG_DEBUG("Host hid polling thread created name:%s pid:%d fd:%d",
            BT_HH_THREAD, p_dev->pid, p_dev->fd);

  pfds[0].fd = p_dev->fd;
  pfds[0].events = POLLIN;
@@ -265,6 +267,7 @@ static void* btif_hh_poll_event_thread(void* arg) {
  }

  p_dev->hh_poll_thread_id = -1;
  p_dev->pid = -1;
  return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ inline std::string btif_hh_status_text(const BTIF_HH_STATUS& status) {
}
#undef CASE_RETURN_TEXT

// Shared with uhid polling thread
typedef struct {
  bthh_connection_state_t dev_status;
  uint8_t dev_handle;
@@ -85,6 +86,7 @@ typedef struct {
  int fd;
  bool ready_for_data;
  pthread_t hh_poll_thread_id;
  pid_t pid{-1};
  uint8_t hh_keep_polling;
  alarm_t* vup_timer;
  fixed_queue_t* get_rpt_id_queue;