| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_device_android.h" | 5 #include "device/bluetooth/bluetooth_device_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void BluetoothDeviceAndroid::OnGattServicesDiscovered( | 229 void BluetoothDeviceAndroid::OnGattServicesDiscovered( |
| 230 JNIEnv* env, | 230 JNIEnv* env, |
| 231 const JavaParamRef<jobject>& jcaller) { | 231 const JavaParamRef<jobject>& jcaller) { |
| 232 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), | 232 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), |
| 233 GattServicesDiscovered(GetAdapter(), this)); | 233 GattServicesDiscovered(GetAdapter(), this)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void BluetoothDeviceAndroid::CreateGattRemoteService( | 236 void BluetoothDeviceAndroid::CreateGattRemoteService( |
| 237 JNIEnv* env, | 237 JNIEnv* env, |
| 238 const JavaParamRef<jobject>& caller, | 238 const JavaParamRef<jobject>& caller, |
| 239 const JavaParamRef<jstring>& instanceId, | 239 const JavaParamRef<jstring>& instance_id, |
| 240 const JavaParamRef<jobject>& | 240 const JavaParamRef<jobject>& |
| 241 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper | 241 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper |
| 242 std::string instanceIdString = | 242 std::string instance_id_string = |
| 243 base::android::ConvertJavaStringToUTF8(env, instanceId); | 243 base::android::ConvertJavaStringToUTF8(env, instance_id); |
| 244 | 244 |
| 245 if (gatt_services_.contains(instanceIdString)) | 245 if (gatt_services_.contains(instance_id_string)) |
| 246 return; | 246 return; |
| 247 | 247 |
| 248 BluetoothDevice::GattServiceMap::iterator service_iterator = | 248 BluetoothDevice::GattServiceMap::iterator service_iterator = |
| 249 gatt_services_.set(instanceIdString, | 249 gatt_services_.set(instance_id_string, |
| 250 BluetoothRemoteGattServiceAndroid::Create( | 250 BluetoothRemoteGattServiceAndroid::Create( |
| 251 GetAdapter(), this, bluetooth_gatt_service_wrapper, | 251 GetAdapter(), this, bluetooth_gatt_service_wrapper, |
| 252 instanceIdString, j_device_.obj())); | 252 instance_id_string, j_device_.obj())); |
| 253 | 253 |
| 254 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), | 254 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), |
| 255 GattServiceAdded(adapter_, this, service_iterator->second)); | 255 GattServiceAdded(adapter_, this, service_iterator->second)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) | 258 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) |
| 259 : BluetoothDevice(adapter) {} | 259 : BluetoothDevice(adapter) {} |
| 260 | 260 |
| 261 std::string BluetoothDeviceAndroid::GetDeviceName() const { | 261 std::string BluetoothDeviceAndroid::GetDeviceName() const { |
| 262 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( | 262 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( |
| 263 AttachCurrentThread(), j_device_.obj())); | 263 AttachCurrentThread(), j_device_.obj())); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 266 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
| 267 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 267 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
| 268 AttachCurrentThread(), j_device_.obj(), | 268 AttachCurrentThread(), j_device_.obj(), |
| 269 base::android::GetApplicationContext()); | 269 base::android::GetApplicationContext()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void BluetoothDeviceAndroid::DisconnectGatt() { | 272 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 273 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 273 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
| 274 j_device_.obj()); | 274 j_device_.obj()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace device | 277 } // namespace device |
| OLD | NEW |