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 "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" | 5 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 callback) { | 42 callback) { |
43 } | 43 } |
44 | 44 |
45 FakeBluetoothGattCharacteristicClient::Properties::~Properties() { | 45 FakeBluetoothGattCharacteristicClient::Properties::~Properties() { |
46 } | 46 } |
47 | 47 |
48 void FakeBluetoothGattCharacteristicClient::Properties::Get( | 48 void FakeBluetoothGattCharacteristicClient::Properties::Get( |
49 dbus::PropertyBase* property, | 49 dbus::PropertyBase* property, |
50 dbus::PropertySet::GetCallback callback) { | 50 dbus::PropertySet::GetCallback callback) { |
51 VLOG(1) << "Get " << property->name(); | 51 VLOG(1) << "Get " << property->name(); |
52 callback.Run(false); | 52 |
| 53 // TODO(armansito): Return success or failure here based on characteristic |
| 54 // read permission. |
| 55 callback.Run(true); |
53 } | 56 } |
54 | 57 |
55 void FakeBluetoothGattCharacteristicClient::Properties::GetAll() { | 58 void FakeBluetoothGattCharacteristicClient::Properties::GetAll() { |
56 VLOG(1) << "GetAll"; | 59 VLOG(1) << "GetAll"; |
57 } | 60 } |
58 | 61 |
59 void FakeBluetoothGattCharacteristicClient::Properties::Set( | 62 void FakeBluetoothGattCharacteristicClient::Properties::Set( |
60 dbus::PropertyBase* property, | 63 dbus::PropertyBase* property, |
61 dbus::PropertySet::SetCallback callback) { | 64 dbus::PropertySet::SetCallback callback) { |
62 VLOG(1) << "Set " << property->name(); | 65 VLOG(1) << "Set " << property->name(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 112 } |
110 | 113 |
111 FakeBluetoothGattCharacteristicClient::Properties* | 114 FakeBluetoothGattCharacteristicClient::Properties* |
112 FakeBluetoothGattCharacteristicClient::GetProperties( | 115 FakeBluetoothGattCharacteristicClient::GetProperties( |
113 const dbus::ObjectPath& object_path) { | 116 const dbus::ObjectPath& object_path) { |
114 if (object_path.value() == heart_rate_measurement_path_) { | 117 if (object_path.value() == heart_rate_measurement_path_) { |
115 DCHECK(heart_rate_measurement_properties_.get()); | 118 DCHECK(heart_rate_measurement_properties_.get()); |
116 return heart_rate_measurement_properties_.get(); | 119 return heart_rate_measurement_properties_.get(); |
117 } | 120 } |
118 if (object_path.value() == body_sensor_location_path_) { | 121 if (object_path.value() == body_sensor_location_path_) { |
119 DCHECK(heart_rate_measurement_properties_.get()); | 122 DCHECK(body_sensor_location_properties_.get()); |
120 return heart_rate_measurement_properties_.get(); | 123 return body_sensor_location_properties_.get(); |
121 } | 124 } |
122 if (object_path.value() == heart_rate_control_point_path_) { | 125 if (object_path.value() == heart_rate_control_point_path_) { |
123 DCHECK(heart_rate_control_point_properties_.get()); | 126 DCHECK(heart_rate_control_point_properties_.get()); |
124 return heart_rate_control_point_properties_.get(); | 127 return heart_rate_control_point_properties_.get(); |
125 } | 128 } |
126 return NULL; | 129 return NULL; |
127 } | 130 } |
128 | 131 |
129 void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( | 132 void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( |
130 const dbus::ObjectPath& service_path) { | 133 const dbus::ObjectPath& service_path) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 heart_rate_measurement_properties_.reset(); | 222 heart_rate_measurement_properties_.reset(); |
220 body_sensor_location_properties_.reset(); | 223 body_sensor_location_properties_.reset(); |
221 heart_rate_control_point_properties_.reset(); | 224 heart_rate_control_point_properties_.reset(); |
222 | 225 |
223 heart_rate_measurement_path_.clear(); | 226 heart_rate_measurement_path_.clear(); |
224 body_sensor_location_path_.clear(); | 227 body_sensor_location_path_.clear(); |
225 heart_rate_control_point_path_.clear(); | 228 heart_rate_control_point_path_.clear(); |
226 heart_rate_visible_ = false; | 229 heart_rate_visible_ = false; |
227 } | 230 } |
228 | 231 |
| 232 dbus::ObjectPath |
| 233 FakeBluetoothGattCharacteristicClient::GetHeartRateMeasurementPath() const { |
| 234 return dbus::ObjectPath(heart_rate_measurement_path_); |
| 235 } |
| 236 |
| 237 dbus::ObjectPath |
| 238 FakeBluetoothGattCharacteristicClient::GetBodySensorLocationPath() const { |
| 239 return dbus::ObjectPath(body_sensor_location_path_); |
| 240 } |
| 241 |
| 242 dbus::ObjectPath |
| 243 FakeBluetoothGattCharacteristicClient::GetHeartRateControlPointPath() const { |
| 244 return dbus::ObjectPath(heart_rate_control_point_path_); |
| 245 } |
| 246 |
229 void FakeBluetoothGattCharacteristicClient::OnPropertyChanged( | 247 void FakeBluetoothGattCharacteristicClient::OnPropertyChanged( |
230 const dbus::ObjectPath& object_path, | 248 const dbus::ObjectPath& object_path, |
231 const std::string& property_name) { | 249 const std::string& property_name) { |
232 VLOG(2) << "Characteristic property changed: " << object_path.value() | 250 VLOG(2) << "Characteristic property changed: " << object_path.value() |
233 << ": " << property_name; | 251 << ": " << property_name; |
234 | 252 |
235 FOR_EACH_OBSERVER(BluetoothGattCharacteristicClient::Observer, observers_, | 253 FOR_EACH_OBSERVER(BluetoothGattCharacteristicClient::Observer, observers_, |
236 GattCharacteristicPropertyChanged( | 254 GattCharacteristicPropertyChanged( |
237 object_path, property_name)); | 255 object_path, property_name)); |
238 | 256 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 DCHECK(heart_rate_visible_ != heart_rate_measurement_path_.empty()); | 351 DCHECK(heart_rate_visible_ != heart_rate_measurement_path_.empty()); |
334 DCHECK(heart_rate_visible_ != body_sensor_location_path_.empty()); | 352 DCHECK(heart_rate_visible_ != body_sensor_location_path_.empty()); |
335 DCHECK(heart_rate_visible_ != heart_rate_control_point_path_.empty()); | 353 DCHECK(heart_rate_visible_ != heart_rate_control_point_path_.empty()); |
336 DCHECK(heart_rate_visible_ == !!heart_rate_measurement_properties_.get()); | 354 DCHECK(heart_rate_visible_ == !!heart_rate_measurement_properties_.get()); |
337 DCHECK(heart_rate_visible_ == !!body_sensor_location_properties_.get()); | 355 DCHECK(heart_rate_visible_ == !!body_sensor_location_properties_.get()); |
338 DCHECK(heart_rate_visible_ == !!heart_rate_control_point_properties_.get()); | 356 DCHECK(heart_rate_visible_ == !!heart_rate_control_point_properties_.get()); |
339 return heart_rate_visible_; | 357 return heart_rate_visible_; |
340 } | 358 } |
341 | 359 |
342 } // namespace chromeos | 360 } // namespace chromeos |
OLD | NEW |