Without thread assiciation callbacks are not received by Java.
They are blocked by JNI:
E/BluetoothServiceJni( 2844): Callback env check fail: env: 0x0, callback: 0x0
E/BluetoothServiceJni( 2844): Callback: 'adapter_state_change_callback' is not
called on the correct thread
bt_hal_cbacks->adapter_properties_cb(ev->status, ev->num_props, props);
}
+void bt_thread_associate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(ASSOCIATE_JVM);
+}
+
+void bt_thread_disassociate(void)
+{
+ if (bt_hal_cbacks->thread_evt_cb)
+ bt_hal_cbacks->thread_evt_cb(DISASSOCIATE_JVM);
+}
+
/* will be called from notification thread context */
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
{
ssize_t ret;
int fd;
+ bt_thread_associate();
+
while (true) {
memset(&msg, 0, sizeof(msg));
memset(buf, 0, sizeof(buf));
close(notif_sk);
notif_sk = -1;
+ bt_thread_disassociate();
+
DBG("exit");
return NULL;
btav_interface_t *bt_get_av_interface(void);
void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);
+void bt_thread_associate(void);
+void bt_thread_disassociate(void);