| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return 0; | 96 return 0; |
| 97 } | 97 } |
| 98 | 98 |
| 99 uint16_t BluetoothDeviceAndroid::GetAppearance() const { | 99 uint16_t BluetoothDeviceAndroid::GetAppearance() const { |
| 100 // TODO(crbug.com/588083): Implementing GetAppearance() | 100 // TODO(crbug.com/588083): Implementing GetAppearance() |
| 101 // on mac, win, and android platforms for chrome | 101 // on mac, win, and android platforms for chrome |
| 102 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 base::Optional<std::string> BluetoothDeviceAndroid::GetName() const { |
| 107 auto name = Java_ChromeBluetoothDevice_getName(AttachCurrentThread(), |
| 108 j_device_.obj()); |
| 109 if (name.is_null()) |
| 110 return base::nullopt; |
| 111 return ConvertJavaStringToUTF8(name); |
| 112 } |
| 113 |
| 106 bool BluetoothDeviceAndroid::IsPaired() const { | 114 bool BluetoothDeviceAndroid::IsPaired() const { |
| 107 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), | 115 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), |
| 108 j_device_.obj()); | 116 j_device_.obj()); |
| 109 } | 117 } |
| 110 | 118 |
| 111 bool BluetoothDeviceAndroid::IsConnected() const { | 119 bool BluetoothDeviceAndroid::IsConnected() const { |
| 112 return IsGattConnected(); | 120 return IsGattConnected(); |
| 113 } | 121 } |
| 114 | 122 |
| 115 bool BluetoothDeviceAndroid::IsGattConnected() const { | 123 bool BluetoothDeviceAndroid::IsGattConnected() const { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 BluetoothRemoteGattServiceAndroid::Create( | 281 BluetoothRemoteGattServiceAndroid::Create( |
| 274 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, | 282 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, |
| 275 instance_id_string, j_device_.obj())); | 283 instance_id_string, j_device_.obj())); |
| 276 | 284 |
| 277 adapter_->NotifyGattServiceAdded(service_iterator->second); | 285 adapter_->NotifyGattServiceAdded(service_iterator->second); |
| 278 } | 286 } |
| 279 | 287 |
| 280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) | 288 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) |
| 281 : BluetoothDevice(adapter) {} | 289 : BluetoothDevice(adapter) {} |
| 282 | 290 |
| 283 std::string BluetoothDeviceAndroid::GetDeviceName() const { | |
| 284 auto device_name = Java_ChromeBluetoothDevice_getDeviceName( | |
| 285 AttachCurrentThread(), j_device_.obj()); | |
| 286 | |
| 287 if (device_name.is_null()) { | |
| 288 return ""; | |
| 289 } | |
| 290 return ConvertJavaStringToUTF8(device_name); | |
| 291 } | |
| 292 | |
| 293 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 291 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
| 294 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 292 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
| 295 AttachCurrentThread(), j_device_.obj(), | 293 AttachCurrentThread(), j_device_.obj(), |
| 296 base::android::GetApplicationContext()); | 294 base::android::GetApplicationContext()); |
| 297 } | 295 } |
| 298 | 296 |
| 299 void BluetoothDeviceAndroid::DisconnectGatt() { | 297 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 300 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 298 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
| 301 j_device_.obj()); | 299 j_device_.obj()); |
| 302 } | 300 } |
| 303 | 301 |
| 304 } // namespace device | 302 } // namespace device |
| OLD | NEW |