Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2594)

Unified Diff: device/bluetooth/bluetooth_adapter_android.cc

Issue 1119113002: bluetooth: Initial JNI setup for device/bluetooth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge GN files, removes circular includes. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_android.cc
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index 9ca54df3e5630dc6f6aefb51216186dfa826fd9c..0d4f1408f5bddf7bdd1db90218a2c122b35f9edc 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -4,10 +4,14 @@
#include "device/bluetooth/bluetooth_adapter_android.h"
+#include "base/android/jni_android.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "device/bluetooth/bluetooth_advertisement.h"
+#include "jni/BluetoothAdapter_jni.h"
+
+using base::android::AttachCurrentThread;
namespace device {
@@ -18,11 +22,22 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
}
// static
-base::WeakPtr<BluetoothAdapter> BluetoothAdapterAndroid::CreateAdapter() {
+base::WeakPtr<BluetoothAdapterAndroid>
+BluetoothAdapterAndroid::CreateAdapter() {
BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
return adapter->weak_ptr_factory_.GetWeakPtr();
}
+// static
+bool BluetoothAdapterAndroid::RegisterJNI(JNIEnv* env) {
+ return RegisterNativesImpl(env); // Generated in BluetoothAdapter_jni.h
+}
+
+bool BluetoothAdapterAndroid::HasBluetoothPermission() const {
+ return Java_BluetoothAdapter_hasBluetoothPermission(
+ AttachCurrentThread(), j_bluetooth_adapter_.obj());
+}
+
std::string BluetoothAdapterAndroid::GetAddress() const {
return address_;
}
@@ -108,6 +123,8 @@ void BluetoothAdapterAndroid::RegisterAdvertisement(
}
BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) {
+ j_bluetooth_adapter_.Reset(Java_BluetoothAdapter_create(
+ AttachCurrentThread(), base::android::GetApplicationContext()));
}
BluetoothAdapterAndroid::~BluetoothAdapterAndroid() {

Powered by Google App Engine
This is Rietveld 408576698