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

Unified Diff: device/bluetooth/bluetooth_adapter_android.cc

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: Created 5 years, 5 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 489050c005e34178f2e3256f2d6bd9cf7ff90d5b..1b2f862e2480d35e64b8e6f0bb3350f7a28c44f4 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -11,6 +11,7 @@
#include "base/thread_task_runner_handle.h"
#include "device/bluetooth/android/wrappers.h"
#include "device/bluetooth/bluetooth_advertisement.h"
+#include "device/bluetooth/bluetooth_device_android.h"
#include "jni/ChromeBluetoothAdapter_jni.h"
using base::android::AttachCurrentThread;
@@ -131,6 +132,28 @@ void BluetoothAdapterAndroid::OnScanFailed(JNIEnv* env, jobject obj) {
MarkDiscoverySessionsAsInactive();
}
+void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
+ JNIEnv* env,
+ jobject obj,
Jeffrey Yasskin 2015/07/07 00:11:14 |obj| isn't used? Wildly guessing at why it's ther
scheib 2015/07/08 00:49:10 :( Yes, this seems unfortunate that JNI presumes t
+ const jstring& jaddress,
+ jobject bluetooth_device_wrapper,
+ jobject advertised_uuids) {
+ BluetoothDevice*& device = devices_[ConvertJavaStringToUTF8(env, jaddress)];
+ if (!device) {
+ device = BluetoothDeviceAndroid::Create(bluetooth_device_wrapper);
+ static_cast<BluetoothDeviceAndroid*>(device)
+ ->UpdateAdvertisedUUIDs(advertised_uuids);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceAdded(this, device));
+ } else {
+ if (static_cast<BluetoothDeviceAndroid*>(device)
+ ->UpdateAdvertisedUUIDs(advertised_uuids)) {
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceChanged(this, device));
+ }
+ }
+}
+
BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) {
}

Powered by Google App Engine
This is Rietveld 408576698