OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_remote_gatt_service_android.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_service_android.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "device/bluetooth/bluetooth_adapter_android.h" | 11 #include "device/bluetooth/bluetooth_adapter_android.h" |
12 #include "device/bluetooth/bluetooth_device_android.h" | 12 #include "device/bluetooth/bluetooth_device_android.h" |
13 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" | 13 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" |
14 #include "jni/ChromeBluetoothRemoteGattService_jni.h" | 14 #include "jni/ChromeBluetoothRemoteGattService_jni.h" |
15 | 15 |
16 using base::android::AttachCurrentThread; | 16 using base::android::AttachCurrentThread; |
17 using base::android::JavaParamRef; | 17 using base::android::JavaParamRef; |
| 18 using base::android::JavaRef; |
18 | 19 |
19 namespace device { | 20 namespace device { |
20 | 21 |
21 // static | 22 // static |
22 std::unique_ptr<BluetoothRemoteGattServiceAndroid> | 23 std::unique_ptr<BluetoothRemoteGattServiceAndroid> |
23 BluetoothRemoteGattServiceAndroid::Create( | 24 BluetoothRemoteGattServiceAndroid::Create( |
24 BluetoothAdapterAndroid* adapter, | 25 BluetoothAdapterAndroid* adapter, |
25 BluetoothDeviceAndroid* device, | 26 BluetoothDeviceAndroid* device, |
26 jobject /* BluetoothGattServiceWrapper */ bluetooth_gatt_service_wrapper, | 27 const JavaRef<jobject>& |
| 28 bluetooth_gatt_service_wrapper, // BluetoothGattServiceWrapper |
27 const std::string& instance_id, | 29 const std::string& instance_id, |
28 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device) { | 30 const JavaRef<jobject>& chrome_bluetooth_device) { // ChromeBluetoothDevice |
29 std::unique_ptr<BluetoothRemoteGattServiceAndroid> service( | 31 std::unique_ptr<BluetoothRemoteGattServiceAndroid> service( |
30 new BluetoothRemoteGattServiceAndroid(adapter, device, instance_id)); | 32 new BluetoothRemoteGattServiceAndroid(adapter, device, instance_id)); |
31 | 33 |
32 JNIEnv* env = AttachCurrentThread(); | 34 JNIEnv* env = AttachCurrentThread(); |
33 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create( | 35 service->j_service_.Reset(Java_ChromeBluetoothRemoteGattService_create( |
34 env, reinterpret_cast<intptr_t>(service.get()), | 36 env, reinterpret_cast<intptr_t>(service.get()), |
35 bluetooth_gatt_service_wrapper, | 37 bluetooth_gatt_service_wrapper, |
36 base::android::ConvertUTF8ToJavaString(env, instance_id), | 38 base::android::ConvertUTF8ToJavaString(env, instance_id), |
37 chrome_bluetooth_device)); | 39 chrome_bluetooth_device)); |
38 | 40 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const { | 184 void BluetoothRemoteGattServiceAndroid::EnsureCharacteristicsCreated() const { |
183 if (!characteristics_.empty()) | 185 if (!characteristics_.empty()) |
184 return; | 186 return; |
185 | 187 |
186 // Java call | 188 // Java call |
187 Java_ChromeBluetoothRemoteGattService_createCharacteristics( | 189 Java_ChromeBluetoothRemoteGattService_createCharacteristics( |
188 AttachCurrentThread(), j_service_); | 190 AttachCurrentThread(), j_service_); |
189 } | 191 } |
190 | 192 |
191 } // namespace device | 193 } // namespace device |
OLD | NEW |