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

Side by Side Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1681853003: Add BluetoothRemoteGattServiceWin to BluetoothDeviceWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add PlatformSupportsLowEnergy check in the unittests Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 gatt_services_.clear(); 238 gatt_services_.clear();
239 SetGattServicesDiscoveryComplete(false); 239 SetGattServicesDiscoveryComplete(false);
240 DidDisconnectGatt(); 240 DidDisconnectGatt();
241 } 241 }
242 } 242 }
243 243
244 void BluetoothDeviceAndroid::OnGattServicesDiscovered( 244 void BluetoothDeviceAndroid::OnGattServicesDiscovered(
245 JNIEnv* env, 245 JNIEnv* env,
246 const JavaParamRef<jobject>& jcaller) { 246 const JavaParamRef<jobject>& jcaller) {
247 SetGattServicesDiscoveryComplete(true); 247 SetGattServicesDiscoveryComplete(true);
248 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), 248 adapter_->NotifyGattServicesDiscovered(this);
249 GattServicesDiscovered(GetAdapter(), this));
250 } 249 }
251 250
252 void BluetoothDeviceAndroid::CreateGattRemoteService( 251 void BluetoothDeviceAndroid::CreateGattRemoteService(
253 JNIEnv* env, 252 JNIEnv* env,
254 const JavaParamRef<jobject>& caller, 253 const JavaParamRef<jobject>& caller,
255 const JavaParamRef<jstring>& instance_id, 254 const JavaParamRef<jstring>& instance_id,
256 const JavaParamRef<jobject>& 255 const JavaParamRef<jobject>&
257 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper 256 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper
258 std::string instance_id_string = 257 std::string instance_id_string =
259 base::android::ConvertJavaStringToUTF8(env, instance_id); 258 base::android::ConvertJavaStringToUTF8(env, instance_id);
260 259
261 if (gatt_services_.contains(instance_id_string)) 260 if (gatt_services_.contains(instance_id_string))
262 return; 261 return;
263 262
264 BluetoothDevice::GattServiceMap::iterator service_iterator = 263 BluetoothDevice::GattServiceMap::iterator service_iterator =
265 gatt_services_.set(instance_id_string, 264 gatt_services_.set(
266 BluetoothRemoteGattServiceAndroid::Create( 265 instance_id_string,
267 GetAdapter(), this, bluetooth_gatt_service_wrapper, 266 BluetoothRemoteGattServiceAndroid::Create(
268 instance_id_string, j_device_.obj())); 267 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper,
268 instance_id_string, j_device_.obj()));
269 269
270 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), 270 adapter_->NotifyGattServiceAdded(service_iterator->second);
271 GattServiceAdded(adapter_, this, service_iterator->second));
272 } 271 }
273 272
274 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 273 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
275 : BluetoothDevice(adapter) {} 274 : BluetoothDevice(adapter) {}
276 275
277 std::string BluetoothDeviceAndroid::GetDeviceName() const { 276 std::string BluetoothDeviceAndroid::GetDeviceName() const {
278 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( 277 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
279 AttachCurrentThread(), j_device_.obj())); 278 AttachCurrentThread(), j_device_.obj()));
280 } 279 }
281 280
282 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 281 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
283 Java_ChromeBluetoothDevice_createGattConnectionImpl( 282 Java_ChromeBluetoothDevice_createGattConnectionImpl(
284 AttachCurrentThread(), j_device_.obj(), 283 AttachCurrentThread(), j_device_.obj(),
285 base::android::GetApplicationContext()); 284 base::android::GetApplicationContext());
286 } 285 }
287 286
288 void BluetoothDeviceAndroid::DisconnectGatt() { 287 void BluetoothDeviceAndroid::DisconnectGatt() {
289 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 288 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
290 j_device_.obj()); 289 j_device_.obj());
291 } 290 }
292 291
293 } // namespace device 292 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_android.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698