Loading core/jni/android_bluetooth_common.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,8 @@ struct event_loop_native_data_t { int envVer; int envVer; /* reference to our java self */ /* reference to our java self */ jobject me; jobject me; /* flag to indicate if the event loop thread is running */ bool running; }; }; struct _Properties { struct _Properties { Loading core/jni/android_server_BluetoothEventLoop.cpp +7 −2 Original line number Original line Diff line number Diff line Loading @@ -548,6 +548,8 @@ static void *eventLoopMain(void *ptr) { dbus_connection_set_watch_functions(nat->conn, dbusAddWatch, dbus_connection_set_watch_functions(nat->conn, dbusAddWatch, dbusRemoveWatch, dbusToggleWatch, ptr, NULL); dbusRemoveWatch, dbusToggleWatch, ptr, NULL); nat->running = true; while (1) { while (1) { for (int i = 0; i < nat->pollMemberCount; i++) { for (int i = 0; i < nat->pollMemberCount; i++) { if (!nat->pollData[i].revents) { if (!nat->pollData[i].revents) { Loading Loading @@ -607,6 +609,8 @@ static jboolean startEventLoopNative(JNIEnv *env, jobject object) { pthread_mutex_lock(&(nat->thread_mutex)); pthread_mutex_lock(&(nat->thread_mutex)); nat->running = false; if (nat->pollData) { if (nat->pollData) { LOGW("trying to start EventLoop a second time!"); LOGW("trying to start EventLoop a second time!"); pthread_mutex_unlock( &(nat->thread_mutex) ); pthread_mutex_unlock( &(nat->thread_mutex) ); Loading Loading @@ -703,6 +707,7 @@ static void stopEventLoopNative(JNIEnv *env, jobject object) { nat->controlFdW = 0; nat->controlFdW = 0; close(fd); close(fd); } } nat->running = false; pthread_mutex_unlock(&(nat->thread_mutex)); pthread_mutex_unlock(&(nat->thread_mutex)); #endif // HAVE_BLUETOOTH #endif // HAVE_BLUETOOTH } } Loading @@ -713,7 +718,7 @@ static jboolean isEventLoopRunningNative(JNIEnv *env, jobject object) { native_data_t *nat = get_native_data(env, object); native_data_t *nat = get_native_data(env, object); pthread_mutex_lock(&(nat->thread_mutex)); pthread_mutex_lock(&(nat->thread_mutex)); if (nat->pollData) { if (nat->running) { result = JNI_TRUE; result = JNI_TRUE; } } pthread_mutex_unlock(&(nat->thread_mutex)); pthread_mutex_unlock(&(nat->thread_mutex)); Loading Loading
core/jni/android_bluetooth_common.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -88,6 +88,8 @@ struct event_loop_native_data_t { int envVer; int envVer; /* reference to our java self */ /* reference to our java self */ jobject me; jobject me; /* flag to indicate if the event loop thread is running */ bool running; }; }; struct _Properties { struct _Properties { Loading
core/jni/android_server_BluetoothEventLoop.cpp +7 −2 Original line number Original line Diff line number Diff line Loading @@ -548,6 +548,8 @@ static void *eventLoopMain(void *ptr) { dbus_connection_set_watch_functions(nat->conn, dbusAddWatch, dbus_connection_set_watch_functions(nat->conn, dbusAddWatch, dbusRemoveWatch, dbusToggleWatch, ptr, NULL); dbusRemoveWatch, dbusToggleWatch, ptr, NULL); nat->running = true; while (1) { while (1) { for (int i = 0; i < nat->pollMemberCount; i++) { for (int i = 0; i < nat->pollMemberCount; i++) { if (!nat->pollData[i].revents) { if (!nat->pollData[i].revents) { Loading Loading @@ -607,6 +609,8 @@ static jboolean startEventLoopNative(JNIEnv *env, jobject object) { pthread_mutex_lock(&(nat->thread_mutex)); pthread_mutex_lock(&(nat->thread_mutex)); nat->running = false; if (nat->pollData) { if (nat->pollData) { LOGW("trying to start EventLoop a second time!"); LOGW("trying to start EventLoop a second time!"); pthread_mutex_unlock( &(nat->thread_mutex) ); pthread_mutex_unlock( &(nat->thread_mutex) ); Loading Loading @@ -703,6 +707,7 @@ static void stopEventLoopNative(JNIEnv *env, jobject object) { nat->controlFdW = 0; nat->controlFdW = 0; close(fd); close(fd); } } nat->running = false; pthread_mutex_unlock(&(nat->thread_mutex)); pthread_mutex_unlock(&(nat->thread_mutex)); #endif // HAVE_BLUETOOTH #endif // HAVE_BLUETOOTH } } Loading @@ -713,7 +718,7 @@ static jboolean isEventLoopRunningNative(JNIEnv *env, jobject object) { native_data_t *nat = get_native_data(env, object); native_data_t *nat = get_native_data(env, object); pthread_mutex_lock(&(nat->thread_mutex)); pthread_mutex_lock(&(nat->thread_mutex)); if (nat->pollData) { if (nat->running) { result = JNI_TRUE; result = JNI_TRUE; } } pthread_mutex_unlock(&(nat->thread_mutex)); pthread_mutex_unlock(&(nat->thread_mutex)); Loading