| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/dbus/fake_bluetooth_device_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const char FakeBluetoothDeviceClient::kJustWorksName[] = "Just-Works Device"; | 229 const char FakeBluetoothDeviceClient::kJustWorksName[] = "Just-Works Device"; |
| 230 const uint32_t FakeBluetoothDeviceClient::kJustWorksClass = 0x240428; | 230 const uint32_t FakeBluetoothDeviceClient::kJustWorksClass = 0x240428; |
| 231 | 231 |
| 232 const char FakeBluetoothDeviceClient::kLowEnergyPath[] = "/fake/hci0/devC"; | 232 const char FakeBluetoothDeviceClient::kLowEnergyPath[] = "/fake/hci0/devC"; |
| 233 const char FakeBluetoothDeviceClient::kLowEnergyAddress[] = "00:1A:11:00:15:30"; | 233 const char FakeBluetoothDeviceClient::kLowEnergyAddress[] = "00:1A:11:00:15:30"; |
| 234 const char FakeBluetoothDeviceClient::kLowEnergyName[] = | 234 const char FakeBluetoothDeviceClient::kLowEnergyName[] = |
| 235 "Bluetooth 4.0 Heart Rate Monitor"; | 235 "Bluetooth 4.0 Heart Rate Monitor"; |
| 236 const uint32_t FakeBluetoothDeviceClient::kLowEnergyClass = | 236 const uint32_t FakeBluetoothDeviceClient::kLowEnergyClass = |
| 237 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor." | 237 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor." |
| 238 | 238 |
| 239 const char FakeBluetoothDeviceClient::kDualPath[] = "/fake/hci0/devF"; |
| 240 const char FakeBluetoothDeviceClient::kDualAddress[] = "00:1A:11:00:15:40"; |
| 241 const char FakeBluetoothDeviceClient::kDualName[] = |
| 242 "Bluetooth 4.0 Battery Monitor"; |
| 243 |
| 239 const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] = | 244 const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] = |
| 240 "/fake/hci0/devD"; | 245 "/fake/hci0/devD"; |
| 241 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] = | 246 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] = |
| 242 "20:7D:74:00:00:04"; | 247 "20:7D:74:00:00:04"; |
| 243 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] = | 248 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] = |
| 244 "Paired Unconnectable Device (name)"; | 249 "Paired Unconnectable Device (name)"; |
| 245 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAlias[] = | 250 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAlias[] = |
| 246 "Paired Unconnectable Device (alias)"; | 251 "Paired Unconnectable Device (alias)"; |
| 247 const uint32_t FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass = | 252 const uint32_t FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass = |
| 248 0x000104; | 253 0x000104; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 properties->name.ReplaceValue(kJustWorksName); | 744 properties->name.ReplaceValue(kJustWorksName); |
| 740 properties->name.set_valid(true); | 745 properties->name.set_valid(true); |
| 741 | 746 |
| 742 } else if (device_path == dbus::ObjectPath(kLowEnergyPath)) { | 747 } else if (device_path == dbus::ObjectPath(kLowEnergyPath)) { |
| 743 properties->address.ReplaceValue(kLowEnergyAddress); | 748 properties->address.ReplaceValue(kLowEnergyAddress); |
| 744 properties->bluetooth_class.ReplaceValue(kLowEnergyClass); | 749 properties->bluetooth_class.ReplaceValue(kLowEnergyClass); |
| 745 properties->name.ReplaceValue(kLowEnergyName); | 750 properties->name.ReplaceValue(kLowEnergyName); |
| 746 properties->name.set_valid(true); | 751 properties->name.set_valid(true); |
| 747 properties->services_resolved.ReplaceValue(false); | 752 properties->services_resolved.ReplaceValue(false); |
| 748 properties->type.ReplaceValue(BluetoothDeviceClient::kTypeLe); | 753 properties->type.ReplaceValue(BluetoothDeviceClient::kTypeLe); |
| 749 | 754 properties->uuids.ReplaceValue(std::vector<std::string>( |
| 750 std::vector<std::string> uuids; | 755 {FakeBluetoothGattServiceClient::kHeartRateServiceUUID})); |
| 751 uuids.push_back(FakeBluetoothGattServiceClient::kHeartRateServiceUUID); | 756 } else if (device_path == dbus::ObjectPath(kDualPath)) { |
| 752 properties->uuids.ReplaceValue(uuids); | 757 properties->address.ReplaceValue(kDualAddress); |
| 758 properties->name.ReplaceValue(kDualName); |
| 759 properties->name.set_valid(true); |
| 760 properties->services_resolved.ReplaceValue(false); |
| 761 properties->type.ReplaceValue(BluetoothDeviceClient::kTypeDual); |
| 762 properties->uuids.ReplaceValue(std::vector<std::string>( |
| 763 {FakeBluetoothGattServiceClient::kGenericAccessServiceUUID, |
| 764 FakeBluetoothGattServiceClient::kHeartRateServiceUUID})); |
| 753 } else if (device_path == | 765 } else if (device_path == |
| 754 dbus::ObjectPath(kConnectedTrustedNotPairedDevicePath)) { | 766 dbus::ObjectPath(kConnectedTrustedNotPairedDevicePath)) { |
| 755 properties->address.ReplaceValue(kConnectedTrustedNotPairedDeviceAddress); | 767 properties->address.ReplaceValue(kConnectedTrustedNotPairedDeviceAddress); |
| 756 properties->bluetooth_class.ReplaceValue( | 768 properties->bluetooth_class.ReplaceValue( |
| 757 kConnectedTrustedNotPairedDeviceClass); | 769 kConnectedTrustedNotPairedDeviceClass); |
| 758 properties->trusted.ReplaceValue(true); | 770 properties->trusted.ReplaceValue(true); |
| 759 properties->connected.ReplaceValue(true); | 771 properties->connected.ReplaceValue(true); |
| 760 properties->paired.ReplaceValue(false); | 772 properties->paired.ReplaceValue(false); |
| 761 properties->name.ReplaceValue(kConnectedTrustedNotPairedDeviceName); | 773 properties->name.ReplaceValue(kConnectedTrustedNotPairedDeviceName); |
| 762 properties->name.set_valid(true); | 774 properties->name.set_valid(true); |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 } | 1806 } |
| 1795 properties->type.set_valid(true); | 1807 properties->type.set_valid(true); |
| 1796 | 1808 |
| 1797 properties_map_.insert(std::make_pair(device_path, std::move(properties))); | 1809 properties_map_.insert(std::make_pair(device_path, std::move(properties))); |
| 1798 device_list_.push_back(device_path); | 1810 device_list_.push_back(device_path); |
| 1799 for (auto& observer : observers_) | 1811 for (auto& observer : observers_) |
| 1800 observer.DeviceAdded(device_path); | 1812 observer.DeviceAdded(device_path); |
| 1801 } | 1813 } |
| 1802 | 1814 |
| 1803 } // namespace bluez | 1815 } // namespace bluez |
| OLD | NEW |