| Index: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
|
| diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
|
| index 4402b9fd08c3f434ff039b4d9373c53abb89767d..7b80de0a0bf875bf364bfbe1e0dbfebe5075adfd 100644
|
| --- a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
|
| +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc
|
| @@ -54,6 +54,16 @@ bool CanRead(const std::vector<std::string>& flags) {
|
| return false;
|
| }
|
|
|
| +bool CanNotify(const std::vector<std::string>& flags) {
|
| + if (find(flags.begin(), flags.end(),
|
| + bluetooth_gatt_characteristic::kFlagNotify) != flags.end())
|
| + return true;
|
| + if (find(flags.begin(), flags.end(),
|
| + bluetooth_gatt_characteristic::kFlagIndicate) != flags.end())
|
| + return true;
|
| + return false;
|
| +}
|
| +
|
| } // namespace
|
|
|
| FakeBluetoothGattCharacteristicServiceProvider::
|
| @@ -99,6 +109,7 @@ void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged(
|
| const std::vector<uint8_t>& value) {
|
| VLOG(1) << "Sent characteristic value changed: " << object_path_.value()
|
| << " UUID: " << uuid_;
|
| + sent_value_ = value;
|
| }
|
|
|
| void FakeBluetoothGattCharacteristicServiceProvider::GetValue(
|
| @@ -156,6 +167,31 @@ void FakeBluetoothGattCharacteristicServiceProvider::SetValue(
|
| delegate_->SetValue(value, callback, error_callback);
|
| }
|
|
|
| +bool FakeBluetoothGattCharacteristicServiceProvider::NotificationsChange(
|
| + bool start) {
|
| + VLOG(1) << "GATT characteristic value notification request: "
|
| + << object_path_.value() << " UUID: " << uuid_ << " start=" << start;
|
| + // Check if this characteristic is registered.
|
| + FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
|
| + static_cast<FakeBluetoothGattManagerClient*>(
|
| + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
|
| + if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) {
|
| + VLOG(1) << "GATT characteristic not registered.";
|
| + return false;
|
| + }
|
| +
|
| + if (!CanNotify(flags_)) {
|
| + VLOG(1) << "GATT characteristic not notifiable.";
|
| + return false;
|
| + }
|
| +
|
| + // Pass on to the delegate.
|
| + DCHECK(delegate_);
|
| + start ? delegate_->StartNotifications() : delegate_->StopNotifications();
|
| +
|
| + return true;
|
| +}
|
| +
|
| const dbus::ObjectPath&
|
| FakeBluetoothGattCharacteristicServiceProvider::object_path() const {
|
| return object_path_;
|
|
|