| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, | 274 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, |
| 275 instance_id_string, j_device_.obj())); | 275 instance_id_string, j_device_.obj())); |
| 276 | 276 |
| 277 adapter_->NotifyGattServiceAdded(service_iterator->second); | 277 adapter_->NotifyGattServiceAdded(service_iterator->second); |
| 278 } | 278 } |
| 279 | 279 |
| 280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) | 280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) |
| 281 : BluetoothDevice(adapter) {} | 281 : BluetoothDevice(adapter) {} |
| 282 | 282 |
| 283 std::string BluetoothDeviceAndroid::GetDeviceName() const { | 283 std::string BluetoothDeviceAndroid::GetDeviceName() const { |
| 284 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( | 284 auto device_name = Java_ChromeBluetoothDevice_getDeviceName( |
| 285 AttachCurrentThread(), j_device_.obj())); | 285 AttachCurrentThread(), j_device_.obj()); |
| 286 |
| 287 if (device_name.is_null()) { |
| 288 return ""; |
| 289 } |
| 290 return ConvertJavaStringToUTF8(device_name); |
| 286 } | 291 } |
| 287 | 292 |
| 288 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 293 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
| 289 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 294 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
| 290 AttachCurrentThread(), j_device_.obj(), | 295 AttachCurrentThread(), j_device_.obj(), |
| 291 base::android::GetApplicationContext()); | 296 base::android::GetApplicationContext()); |
| 292 } | 297 } |
| 293 | 298 |
| 294 void BluetoothDeviceAndroid::DisconnectGatt() { | 299 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 295 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 300 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
| 296 j_device_.obj()); | 301 j_device_.obj()); |
| 297 } | 302 } |
| 298 | 303 |
| 299 } // namespace device | 304 } // namespace device |
| OLD | NEW |