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() { |