Index: device/bluetooth/bluetooth_device_android.cc |
diff --git a/device/bluetooth/bluetooth_device_android.cc b/device/bluetooth/bluetooth_device_android.cc |
index 2d9c954a1445c2945a00849903792808f3ea2b76..1066ac4b39f822d44debff43ea26f974beaa9bfc 100644 |
--- a/device/bluetooth/bluetooth_device_android.cc |
+++ b/device/bluetooth/bluetooth_device_android.cc |
@@ -7,7 +7,9 @@ |
#include "base/android/jni_android.h" |
#include "base/android/jni_array.h" |
#include "base/android/jni_string.h" |
+#include "base/strings/stringprintf.h" |
#include "device/bluetooth/bluetooth_adapter_android.h" |
+#include "device/bluetooth/bluetooth_remote_gatt_service_android.h" |
#include "jni/ChromeBluetoothDevice_jni.h" |
using base::android::AttachCurrentThread; |
@@ -221,6 +223,29 @@ void BluetoothDeviceAndroid::OnConnectionStateChange(JNIEnv* env, |
} |
} |
+void BluetoothDeviceAndroid::CreateGattRemoteService( |
+ JNIEnv* env, |
+ jobject caller, |
+ int32_t instanceId, |
+ jobject bluetooth_gatt_service_wrapper // Java Type: |
+ // BluetoothGattServiceWrapper |
+ ) { |
+ std::string instanceIdString = base::StringPrintf("%d", instanceId); |
+ |
+ if (gatt_services_.contains(instanceIdString)) |
+ return; |
+ |
+ BluetoothRemoteGattServiceAndroid* service = |
+ BluetoothRemoteGattServiceAndroid::Create( |
+ GetAdapter(), this, bluetooth_gatt_service_wrapper, instanceIdString); |
+ |
+ gatt_services_.set(instanceIdString, |
+ make_scoped_ptr<BluetoothGattService>(service)); |
+ |
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), |
+ GattServiceAdded(adapter_, this, service)); |
+} |
+ |
BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) |
: BluetoothDevice(adapter) {} |