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

Commit 42594fed authored by Dowon Park's avatar Dowon Park
Browse files

HH: Fix crash when calling JNI callback using main thread

btif_hh_connect() can be called through main thread and it lead to crash
with following message. "JNI DETECTED ERROR IN APPLICATION: a thread
xxxx is making JNI calls without being attached"
So we fix to switch callback to jni thread.

Bug: 243753956
Tag: #stability
Test: reconnect some mouse after BT turning on
Change-Id: Ib3576bca9026e7fdf164c972f2da22471005e01f
parent 8744afea
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -601,10 +601,13 @@ bt_status_t btif_hh_connect(const RawAddress* bd_addr) {
  btif_hh_cb.pending_conn_address = *bd_addr;
  BTA_HhOpen(*bd_addr);

  // TODO(jpawlowski); make cback accept const and remove tmp!
  auto tmp = *bd_addr;
  HAL_CBACK(bt_hh_callbacks, connection_state_cb, &tmp,
  do_in_jni_thread(
      base::Bind(
          [](RawAddress *bd_addr) {
            HAL_CBACK(bt_hh_callbacks, connection_state_cb, bd_addr,
                BTHH_CONN_STATE_CONNECTING);
          },
          (RawAddress*)bd_addr));
  return BT_STATUS_SUCCESS;
}