Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_device_client.cc

Issue 1979633004: Invoke GattDiscoveryCompleteForService by observing ServicesResolved property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_attr
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath[] = 211 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath[] =
212 "/fake/hci0/devE"; 212 "/fake/hci0/devE";
213 const char 213 const char
214 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceAddress[] = 214 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceAddress[] =
215 "11:22:33:44:55:66"; 215 "11:22:33:44:55:66";
216 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceName[] = 216 const char FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceName[] =
217 "Connected Pairable Device"; 217 "Connected Pairable Device";
218 const uint32_t 218 const uint32_t
219 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceClass = 0x7a020c; 219 FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceClass = 0x7a020c;
220 220
221 const char FakeBluetoothDeviceClient::kCachedLowEnergyPath[] =
222 "/fake/hci0/devF";
223 const char FakeBluetoothDeviceClient::kCachedLowEnergyAddress[] =
224 "02:A5:11:0D:15:40";
225 const char FakeBluetoothDeviceClient::kCachedLowEnergyName[] =
226 "Bluetooth 4.0 Heart Rate Monitor";
227 const uint32_t FakeBluetoothDeviceClient::kCachedLowEnergyClass =
228 0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor."
229
221 FakeBluetoothDeviceClient::Properties::Properties( 230 FakeBluetoothDeviceClient::Properties::Properties(
222 const PropertyChangedCallback& callback) 231 const PropertyChangedCallback& callback)
223 : BluetoothDeviceClient::Properties( 232 : BluetoothDeviceClient::Properties(
224 NULL, 233 NULL,
225 bluetooth_device::kBluetoothDeviceInterface, 234 bluetooth_device::kBluetoothDeviceInterface,
226 callback) {} 235 callback) {}
227 236
228 FakeBluetoothDeviceClient::Properties::~Properties() {} 237 FakeBluetoothDeviceClient::Properties::~Properties() {}
229 238
230 void FakeBluetoothDeviceClient::Properties::Get( 239 void FakeBluetoothDeviceClient::Properties::Get(
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } else if (device_path == 700 } else if (device_path ==
692 dbus::ObjectPath(kConnectedTrustedNotPairedDevicePath)) { 701 dbus::ObjectPath(kConnectedTrustedNotPairedDevicePath)) {
693 properties->address.ReplaceValue(kConnectedTrustedNotPairedDeviceAddress); 702 properties->address.ReplaceValue(kConnectedTrustedNotPairedDeviceAddress);
694 properties->bluetooth_class.ReplaceValue( 703 properties->bluetooth_class.ReplaceValue(
695 kConnectedTrustedNotPairedDeviceClass); 704 kConnectedTrustedNotPairedDeviceClass);
696 properties->trusted.ReplaceValue(true); 705 properties->trusted.ReplaceValue(true);
697 properties->connected.ReplaceValue(true); 706 properties->connected.ReplaceValue(true);
698 properties->paired.ReplaceValue(false); 707 properties->paired.ReplaceValue(false);
699 properties->name.ReplaceValue("Connected Pairable Device"); 708 properties->name.ReplaceValue("Connected Pairable Device");
700 properties->alias.ReplaceValue(kConnectedTrustedNotPairedDeviceName); 709 properties->alias.ReplaceValue(kConnectedTrustedNotPairedDeviceName);
710 } else if (device_path == dbus::ObjectPath(kCachedLowEnergyPath)) {
711 properties->address.ReplaceValue(kLowEnergyAddress);
712 properties->bluetooth_class.ReplaceValue(kLowEnergyClass);
713 properties->name.ReplaceValue("Heart Rate Monitor");
714 properties->alias.ReplaceValue(kLowEnergyName);
715 properties->alias.ReplaceValue(kLowEnergyName);
716 properties->services_resolved.ReplaceValue(false);
717
718 std::vector<std::string> uuids;
719 uuids.push_back(FakeBluetoothGattServiceClient::kHeartRateServiceUUID);
720 properties->uuids.ReplaceValue(uuids);
701 } else { 721 } else {
702 NOTREACHED(); 722 NOTREACHED();
703 } 723 }
704 724
705 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 725 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
706 device_list_.push_back(device_path); 726 device_list_.push_back(device_path);
727
728 // After the new properties| is added to the map, expose the heart rate
729 // service to emulate the device with cached GATT services.
730 if (device_path == dbus::ObjectPath(kCachedLowEnergyPath)) {
731 static_cast<FakeBluetoothGattServiceClient*>(
732 bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient())
733 ->ExposeHeartRateServiceWithoutDelay(device_path);
734 }
735
707 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 736 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_,
708 DeviceAdded(device_path)); 737 DeviceAdded(device_path));
709 } 738 }
710 739
711 void FakeBluetoothDeviceClient::CreateDeviceWithProperties( 740 void FakeBluetoothDeviceClient::CreateDeviceWithProperties(
712 const dbus::ObjectPath& adapter_path, 741 const dbus::ObjectPath& adapter_path,
713 const IncomingDeviceProperties& props) { 742 const IncomingDeviceProperties& props) {
714 dbus::ObjectPath device_path(props.device_path); 743 dbus::ObjectPath device_path(props.device_path);
715 if (std::find(device_list_.begin(), device_list_.end(), device_path) != 744 if (std::find(device_list_.begin(), device_list_.end(), device_path) !=
716 device_list_.end()) 745 device_list_.end())
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 1725
1697 properties->uuids.ReplaceValue(service_uuids); 1726 properties->uuids.ReplaceValue(service_uuids);
1698 1727
1699 properties_map_.insert(std::make_pair(device_path, std::move(properties))); 1728 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
1700 device_list_.push_back(device_path); 1729 device_list_.push_back(device_path);
1701 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, 1730 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_,
1702 DeviceAdded(device_path)); 1731 DeviceAdded(device_path));
1703 } 1732 }
1704 1733
1705 } // namespace bluez 1734 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698