| 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/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 default: | 219 default: |
| 220 VLOG(1) << "Unhandled status: " << status; | 220 VLOG(1) << "Unhandled status: " << status; |
| 221 return DidFailToConnectGatt(ERROR_UNKNOWN); | 221 return DidFailToConnectGatt(ERROR_UNKNOWN); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 void BluetoothDeviceAndroid::CreateGattRemoteService( | 226 void BluetoothDeviceAndroid::CreateGattRemoteService( |
| 227 JNIEnv* env, | 227 JNIEnv* env, |
| 228 jobject caller, | 228 jobject caller, |
| 229 int32_t instanceId, | 229 const jstring& instanceId, |
| 230 jobject bluetooth_gatt_service_wrapper // Java Type: | 230 jobject bluetooth_gatt_service_wrapper // Java Type: |
| 231 // BluetoothGattServiceWrapper | 231 // BluetoothGattServiceWrapper |
| 232 ) { | 232 ) { |
| 233 std::string instanceIdString = base::StringPrintf("%d", instanceId); | 233 std::string instanceIdString = |
| 234 base::android::ConvertJavaStringToUTF8(env, instanceId); |
| 234 | 235 |
| 235 if (gatt_services_.contains(instanceIdString)) | 236 if (gatt_services_.contains(instanceIdString)) |
| 236 return; | 237 return; |
| 237 | 238 |
| 238 BluetoothRemoteGattServiceAndroid* service = | 239 BluetoothRemoteGattServiceAndroid* service = |
| 239 BluetoothRemoteGattServiceAndroid::Create( | 240 BluetoothRemoteGattServiceAndroid::Create( |
| 240 GetAdapter(), this, bluetooth_gatt_service_wrapper, instanceIdString); | 241 GetAdapter(), this, bluetooth_gatt_service_wrapper, instanceIdString); |
| 241 | 242 |
| 242 gatt_services_.set(instanceIdString, | 243 gatt_services_.set(instanceIdString, |
| 243 make_scoped_ptr<BluetoothGattService>(service)); | 244 make_scoped_ptr<BluetoothGattService>(service)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 259 AttachCurrentThread(), j_device_.obj(), | 260 AttachCurrentThread(), j_device_.obj(), |
| 260 base::android::GetApplicationContext()); | 261 base::android::GetApplicationContext()); |
| 261 } | 262 } |
| 262 | 263 |
| 263 void BluetoothDeviceAndroid::DisconnectGatt() { | 264 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 264 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 265 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
| 265 j_device_.obj()); | 266 j_device_.obj()); |
| 266 } | 267 } |
| 267 | 268 |
| 268 } // namespace device | 269 } // namespace device |
| OLD | NEW |