| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 const char FakeBluetoothDeviceClient::kPairingActionConfirmation[] = | 142 const char FakeBluetoothDeviceClient::kPairingActionConfirmation[] = |
| 143 "Confirmation"; | 143 "Confirmation"; |
| 144 const char FakeBluetoothDeviceClient::kPairingActionDisplay[] = "Display"; | 144 const char FakeBluetoothDeviceClient::kPairingActionDisplay[] = "Display"; |
| 145 const char FakeBluetoothDeviceClient::kPairingActionFail[] = "Fail"; | 145 const char FakeBluetoothDeviceClient::kPairingActionFail[] = "Fail"; |
| 146 const char FakeBluetoothDeviceClient::kPairingActionRequest[] = "Request"; | 146 const char FakeBluetoothDeviceClient::kPairingActionRequest[] = "Request"; |
| 147 | 147 |
| 148 const char FakeBluetoothDeviceClient::kPairedDevicePath[] = "/fake/hci0/dev0"; | 148 const char FakeBluetoothDeviceClient::kPairedDevicePath[] = "/fake/hci0/dev0"; |
| 149 const char FakeBluetoothDeviceClient::kPairedDeviceAddress[] = | 149 const char FakeBluetoothDeviceClient::kPairedDeviceAddress[] = |
| 150 "00:11:22:33:44:55"; | 150 "00:11:22:33:44:55"; |
| 151 const char FakeBluetoothDeviceClient::kPairedDeviceName[] = "Fake Device"; | 151 const char FakeBluetoothDeviceClient::kPairedDeviceName[] = |
| 152 "Fake Device (name)"; |
| 153 const char FakeBluetoothDeviceClient::kPairedDeviceAlias[] = |
| 154 "Fake Device (alias)"; |
| 152 const uint32_t FakeBluetoothDeviceClient::kPairedDeviceClass = 0x000104; | 155 const uint32_t FakeBluetoothDeviceClient::kPairedDeviceClass = 0x000104; |
| 153 | 156 |
| 154 const char FakeBluetoothDeviceClient::kLegacyAutopairPath[] = "/fake/hci0/dev1"; | 157 const char FakeBluetoothDeviceClient::kLegacyAutopairPath[] = "/fake/hci0/dev1"; |
| 155 const char FakeBluetoothDeviceClient::kLegacyAutopairAddress[] = | 158 const char FakeBluetoothDeviceClient::kLegacyAutopairAddress[] = |
| 156 "28:CF:DA:00:00:00"; | 159 "28:CF:DA:00:00:00"; |
| 157 const char FakeBluetoothDeviceClient::kLegacyAutopairName[] = | 160 const char FakeBluetoothDeviceClient::kLegacyAutopairName[] = |
| 158 "Bluetooth 2.0 Mouse"; | 161 "Bluetooth 2.0 Mouse"; |
| 159 const uint32_t FakeBluetoothDeviceClient::kLegacyAutopairClass = 0x002580; | 162 const uint32_t FakeBluetoothDeviceClient::kLegacyAutopairClass = 0x002580; |
| 160 | 163 |
| 161 const char FakeBluetoothDeviceClient::kDisplayPinCodePath[] = "/fake/hci0/dev2"; | 164 const char FakeBluetoothDeviceClient::kDisplayPinCodePath[] = "/fake/hci0/dev2"; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 const char FakeBluetoothDeviceClient::kLowEnergyName[] = | 235 const char FakeBluetoothDeviceClient::kLowEnergyName[] = |
| 233 "Bluetooth 4.0 Heart Rate Monitor"; | 236 "Bluetooth 4.0 Heart Rate Monitor"; |
| 234 const uint32_t FakeBluetoothDeviceClient::kLowEnergyClass = | 237 const uint32_t FakeBluetoothDeviceClient::kLowEnergyClass = |
| 235 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor." | 238 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor." |
| 236 | 239 |
| 237 const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] = | 240 const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] = |
| 238 "/fake/hci0/devD"; | 241 "/fake/hci0/devD"; |
| 239 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] = | 242 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] = |
| 240 "20:7D:74:00:00:04"; | 243 "20:7D:74:00:00:04"; |
| 241 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] = | 244 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] = |
| 242 "Paired Unconnectable Device"; | 245 "Paired Unconnectable Device (name)"; |
| 246 const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAlias[] = |
| 247 "Paired Unconnectable Device (alias)"; |
| 243 const uint32_t FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass = | 248 const uint32_t FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass = |
| 244 0x000104; | 249 0x000104; |
| 245 | 250 |
| 246 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath[] = | 251 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath[] = |
| 247 "/fake/hci0/devE"; | 252 "/fake/hci0/devE"; |
| 248 const char | 253 const char |
| 249 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceAddress[] = | 254 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceAddress[] = |
| 250 "11:22:33:44:55:66"; | 255 "11:22:33:44:55:66"; |
| 251 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceName[] = | 256 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceName[] = |
| 252 "Connected Pairable Device"; | 257 "Connected Pairable Device"; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 pairing_cancelled_(false), | 308 pairing_cancelled_(false), |
| 304 connection_rssi_(kUnkownPower), | 309 connection_rssi_(kUnkownPower), |
| 305 transmit_power_(kUnkownPower), | 310 transmit_power_(kUnkownPower), |
| 306 max_transmit_power_(kUnkownPower), | 311 max_transmit_power_(kUnkownPower), |
| 307 delay_start_discovery_(false) { | 312 delay_start_discovery_(false) { |
| 308 std::unique_ptr<Properties> properties(new Properties( | 313 std::unique_ptr<Properties> properties(new Properties( |
| 309 base::Bind(&FakeBluetoothDeviceClient::OnPropertyChanged, | 314 base::Bind(&FakeBluetoothDeviceClient::OnPropertyChanged, |
| 310 base::Unretained(this), dbus::ObjectPath(kPairedDevicePath)))); | 315 base::Unretained(this), dbus::ObjectPath(kPairedDevicePath)))); |
| 311 properties->address.ReplaceValue(kPairedDeviceAddress); | 316 properties->address.ReplaceValue(kPairedDeviceAddress); |
| 312 properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); | 317 properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); |
| 313 properties->name.ReplaceValue("Fake Device (Name)"); | 318 properties->name.ReplaceValue(kPairedDeviceName); |
| 314 properties->alias.ReplaceValue(kPairedDeviceName); | 319 properties->alias.ReplaceValue(kPairedDeviceAlias); |
| 315 properties->paired.ReplaceValue(true); | 320 properties->paired.ReplaceValue(true); |
| 316 properties->trusted.ReplaceValue(true); | 321 properties->trusted.ReplaceValue(true); |
| 317 properties->adapter.ReplaceValue( | 322 properties->adapter.ReplaceValue( |
| 318 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | 323 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
| 319 | 324 |
| 320 std::vector<std::string> uuids; | 325 std::vector<std::string> uuids; |
| 321 uuids.push_back("00001800-0000-1000-8000-00805f9b34fb"); | 326 uuids.push_back("00001800-0000-1000-8000-00805f9b34fb"); |
| 322 uuids.push_back("00001801-0000-1000-8000-00805f9b34fb"); | 327 uuids.push_back("00001801-0000-1000-8000-00805f9b34fb"); |
| 323 properties->uuids.ReplaceValue(uuids); | 328 properties->uuids.ReplaceValue(uuids); |
| 324 | 329 |
| 325 properties->modalias.ReplaceValue("usb:v05ACp030Dd0306"); | 330 properties->modalias.ReplaceValue("usb:v05ACp030Dd0306"); |
| 326 | 331 |
| 327 properties_map_.insert(std::make_pair(dbus::ObjectPath(kPairedDevicePath), | 332 properties_map_.insert(std::make_pair(dbus::ObjectPath(kPairedDevicePath), |
| 328 std::move(properties))); | 333 std::move(properties))); |
| 329 device_list_.push_back(dbus::ObjectPath(kPairedDevicePath)); | 334 device_list_.push_back(dbus::ObjectPath(kPairedDevicePath)); |
| 330 | 335 |
| 331 properties.reset(new Properties(base::Bind( | 336 properties.reset(new Properties(base::Bind( |
| 332 &FakeBluetoothDeviceClient::OnPropertyChanged, base::Unretained(this), | 337 &FakeBluetoothDeviceClient::OnPropertyChanged, base::Unretained(this), |
| 333 dbus::ObjectPath(kPairedUnconnectableDevicePath)))); | 338 dbus::ObjectPath(kPairedUnconnectableDevicePath)))); |
| 334 properties->address.ReplaceValue(kPairedUnconnectableDeviceAddress); | 339 properties->address.ReplaceValue(kPairedUnconnectableDeviceAddress); |
| 335 properties->bluetooth_class.ReplaceValue(kPairedUnconnectableDeviceClass); | 340 properties->bluetooth_class.ReplaceValue(kPairedUnconnectableDeviceClass); |
| 336 properties->name.ReplaceValue("Fake Device 2 (Unconnectable)"); | 341 properties->name.ReplaceValue(kPairedUnconnectableDeviceName); |
| 337 properties->alias.ReplaceValue(kPairedUnconnectableDeviceName); | 342 properties->alias.ReplaceValue(kPairedUnconnectableDeviceAlias); |
| 338 properties->paired.ReplaceValue(true); | 343 properties->paired.ReplaceValue(true); |
| 339 properties->trusted.ReplaceValue(true); | 344 properties->trusted.ReplaceValue(true); |
| 340 properties->adapter.ReplaceValue( | 345 properties->adapter.ReplaceValue( |
| 341 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | 346 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
| 342 | 347 |
| 343 properties->uuids.ReplaceValue(uuids); | 348 properties->uuids.ReplaceValue(uuids); |
| 344 | 349 |
| 345 properties->modalias.ReplaceValue("usb:v05ACp030Dd0306"); | 350 properties->modalias.ReplaceValue("usb:v05ACp030Dd0306"); |
| 346 | 351 |
| 347 properties_map_.insert(std::make_pair( | 352 properties_map_.insert(std::make_pair( |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 } | 1770 } |
| 1766 properties->type.set_valid(true); | 1771 properties->type.set_valid(true); |
| 1767 | 1772 |
| 1768 properties_map_.insert(std::make_pair(device_path, std::move(properties))); | 1773 properties_map_.insert(std::make_pair(device_path, std::move(properties))); |
| 1769 device_list_.push_back(device_path); | 1774 device_list_.push_back(device_path); |
| 1770 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, | 1775 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| 1771 DeviceAdded(device_path)); | 1776 DeviceAdded(device_path)); |
| 1772 } | 1777 } |
| 1773 | 1778 |
| 1774 } // namespace bluez | 1779 } // namespace bluez |
| OLD | NEW |