| 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_remote_gatt_characteristic_android.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 BluetoothUUID BluetoothRemoteGattCharacteristicAndroid::GetUUID() const { | 61 BluetoothUUID BluetoothRemoteGattCharacteristicAndroid::GetUUID() const { |
| 62 return device::BluetoothUUID(ConvertJavaStringToUTF8( | 62 return device::BluetoothUUID(ConvertJavaStringToUTF8( |
| 63 Java_ChromeBluetoothRemoteGattCharacteristic_getUUID( | 63 Java_ChromeBluetoothRemoteGattCharacteristic_getUUID( |
| 64 AttachCurrentThread(), j_characteristic_.obj()))); | 64 AttachCurrentThread(), j_characteristic_.obj()))); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool BluetoothRemoteGattCharacteristicAndroid::IsLocal() const { | 67 bool BluetoothRemoteGattCharacteristicAndroid::IsLocal() const { |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 | 70 |
| 71 const std::vector<uint8>& BluetoothRemoteGattCharacteristicAndroid::GetValue() | 71 const std::vector<uint8_t>& BluetoothRemoteGattCharacteristicAndroid::GetValue() |
| 72 const { | 72 const { |
| 73 return value_; | 73 return value_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 BluetoothGattService* BluetoothRemoteGattCharacteristicAndroid::GetService() | 76 BluetoothGattService* BluetoothRemoteGattCharacteristicAndroid::GetService() |
| 77 const { | 77 const { |
| 78 NOTIMPLEMENTED(); | 78 NOTIMPLEMENTED(); |
| 79 return nullptr; | 79 return nullptr; |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 return nullptr; | 109 return nullptr; |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool BluetoothRemoteGattCharacteristicAndroid::AddDescriptor( | 112 bool BluetoothRemoteGattCharacteristicAndroid::AddDescriptor( |
| 113 BluetoothGattDescriptor* descriptor) { | 113 BluetoothGattDescriptor* descriptor) { |
| 114 NOTIMPLEMENTED(); | 114 NOTIMPLEMENTED(); |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool BluetoothRemoteGattCharacteristicAndroid::UpdateValue( | 118 bool BluetoothRemoteGattCharacteristicAndroid::UpdateValue( |
| 119 const std::vector<uint8>& value) { | 119 const std::vector<uint8_t>& value) { |
| 120 NOTIMPLEMENTED(); | 120 NOTIMPLEMENTED(); |
| 121 return false; | 121 return false; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession( | 124 void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession( |
| 125 const NotifySessionCallback& callback, | 125 const NotifySessionCallback& callback, |
| 126 const ErrorCallback& error_callback) { | 126 const ErrorCallback& error_callback) { |
| 127 // TODO(crbug.com/551634): Check characteristic properties and return a better | 127 // TODO(crbug.com/551634): Check characteristic properties and return a better |
| 128 // error code if notifications aren't permitted. | 128 // error code if notifications aren't permitted. |
| 129 if (Java_ChromeBluetoothRemoteGattCharacteristic_startNotifySession( | 129 if (Java_ChromeBluetoothRemoteGattCharacteristic_startNotifySession( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 158 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); | 158 BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 read_pending_ = true; | 162 read_pending_ = true; |
| 163 read_callback_ = callback; | 163 read_callback_ = callback; |
| 164 read_error_callback_ = error_callback; | 164 read_error_callback_ = error_callback; |
| 165 } | 165 } |
| 166 | 166 |
| 167 void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( | 167 void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( |
| 168 const std::vector<uint8>& new_value, | 168 const std::vector<uint8_t>& new_value, |
| 169 const base::Closure& callback, | 169 const base::Closure& callback, |
| 170 const ErrorCallback& error_callback) { | 170 const ErrorCallback& error_callback) { |
| 171 if (read_pending_ || write_pending_) { | 171 if (read_pending_ || write_pending_) { |
| 172 base::MessageLoop::current()->PostTask( | 172 base::MessageLoop::current()->PostTask( |
| 173 FROM_HERE, base::Bind(error_callback, | 173 FROM_HERE, base::Bind(error_callback, |
| 174 BluetoothGattService::GATT_ERROR_IN_PROGRESS)); | 174 BluetoothGattService::GATT_ERROR_IN_PROGRESS)); |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 | 177 |
| 178 JNIEnv* env = AttachCurrentThread(); | 178 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 write_error_callback.Run( | 233 write_error_callback.Run( |
| 234 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); | 234 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 BluetoothRemoteGattCharacteristicAndroid:: | 238 BluetoothRemoteGattCharacteristicAndroid:: |
| 239 BluetoothRemoteGattCharacteristicAndroid(const std::string& instanceId) | 239 BluetoothRemoteGattCharacteristicAndroid(const std::string& instanceId) |
| 240 : instance_id_(instanceId) {} | 240 : instance_id_(instanceId) {} |
| 241 | 241 |
| 242 } // namespace device | 242 } // namespace device |
| OLD | NEW |