extern bt_status_t do_in_jni_thread(const base::Closure& task);
extern bt_status_t do_in_jni_thread(const tracked_objects::Location& from_here,
const base::Closure& task);
+extern bool is_on_jni_thread();
/**
* This template wraps callback into callback that will be executed on jni
* thread
#include <base/at_exit.h>
#include <base/bind.h>
#include <base/run_loop.h>
+#include <base/threading/platform_thread.h>
#include <base/threading/thread.h>
#include <ctype.h>
#include <dirent.h>
#include "osi/include/thread.h"
#include "stack_manager.h"
+using base::PlatformThread;
using bluetooth::Uuid;
+
/*******************************************************************************
* Constants & Macros
******************************************************************************/
static uid_set_t* uid_set = NULL;
base::MessageLoop* message_loop_ = NULL;
base::RunLoop* jni_run_loop = NULL;
+static base::PlatformThreadId btif_thread_id_ = -1;
/*******************************************************************************
* Static functions
return do_in_jni_thread(FROM_HERE, task);
}
+bool is_on_jni_thread() {
+ return btif_thread_id_ == PlatformThread::CurrentId();
+}
+
/*******************************************************************************
*
* Function btif_is_dut_mode
void run_message_loop(UNUSED_ATTR void* context) {
LOG_INFO(LOG_TAG, "%s entered", __func__);
+ btif_thread_id_ = PlatformThread::CurrentId();
// TODO(jpawlowski): exit_manager should be defined in main(), but there is no
// main method.
delete jni_run_loop;
jni_run_loop = NULL;
+ btif_thread_id_ = -1;
LOG_INFO(LOG_TAG, "%s finished", __func__);
}
/*******************************************************************************