Index: device/bluetooth/dbus/fake_bluetooth_device_client.cc |
diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc |
index 58f694f03cf6e3161e261e099f74dafe446a5215..635c000b3aadec657c914e612ce9c0900aa9eaec 100644 |
--- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc |
+++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc |
@@ -1551,6 +1551,20 @@ void FakeBluetoothDeviceClient::UpdateDeviceRSSI( |
properties->rssi.ReplaceValue(rssi); |
} |
+void FakeBluetoothDeviceClient::UpdateServiceData( |
+ const dbus::ObjectPath& object_path, |
+ const std::unordered_map<std::string, std::vector<uint8_t>>& service_data) { |
+ PropertiesMap::const_iterator iter = properties_map_.find(object_path); |
+ if (iter == properties_map_.end()) { |
+ VLOG(2) << "Fake device does not exist: " << object_path.value(); |
+ return; |
+ } |
+ Properties* properties = iter->second.get(); |
+ DCHECK(properties); |
+ properties->service_data.set_valid(true); |
+ properties->service_data.ReplaceValue(service_data); |
ortuno
2017/03/30 02:58:14
+scheib fyi
*sigh* I wish BlueZ worked like this.
scheib
2017/03/30 03:44:10
Grr... Bluez.
I didn't go dig into Bluez code to
Miao
2017/03/30 21:20:07
As Ortuno mentioned, the current BlueZ caches all
ortuno
2017/03/30 22:18:17
We discussed a solution with puthik a while ago. L
xiaoyinh(OOO Sep 11-29)
2017/03/31 16:26:53
Changed it to merge data like what BlueZ does.
xiaoyinh(OOO Sep 11-29)
2017/03/31 16:26:53
Done.
|
+} |
+ |
void FakeBluetoothDeviceClient::UpdateConnectionInfo( |
uint16_t connection_rssi, |
uint16_t transmit_power, |
@@ -1775,7 +1789,8 @@ void FakeBluetoothDeviceClient::CreateTestDevice( |
const std::string alias, |
const std::string device_address, |
const std::vector<std::string>& service_uuids, |
- device::BluetoothTransport type) { |
+ device::BluetoothTransport type, |
+ const std::unordered_map<std::string, std::vector<uint8_t>>& service_data) { |
// Create a random device path. |
dbus::ObjectPath device_path; |
std::string id; |
@@ -1818,6 +1833,11 @@ void FakeBluetoothDeviceClient::CreateTestDevice( |
} |
properties->type.set_valid(true); |
+ if (!service_data.empty()) { |
+ properties->service_data.ReplaceValue(service_data); |
+ properties->service_data.set_valid(true); |
+ } |
+ |
properties_map_.insert(std::make_pair(device_path, std::move(properties))); |
device_list_.push_back(device_path); |
for (auto& observer : observers_) |