Index: chromeos/dbus/fake_bluetooth_device_client.cc |
diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0b732a7d3a350f0e5fbecf39bd32de0bf2bc79a4 |
--- /dev/null |
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc |
@@ -0,0 +1,559 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chromeos/dbus/fake_bluetooth_device_client.h" |
+ |
+#include <algorithm> |
+#include <map> |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/bind.h" |
+#include "base/logging.h" |
+#include "base/message_loop.h" |
+#include "base/stl_util.h" |
+#include "base/time.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
+#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
+#include "chromeos/dbus/fake_bluetooth_agent_service_provider.h" |
+#include "dbus/object_path.h" |
+#include "third_party/cros_system_api/dbus/service_constants.h" |
+ |
+namespace { |
+ |
+// Default interval between simulated events. |
+const int kSimulationIntervalMs = 750; |
+ |
+} |
+ |
+namespace chromeos { |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kPairedDevicePath( |
+ "/fake/hci0/dev0"); |
+const char FakeBluetoothDeviceClient::kPairedDeviceAddress[] = |
+ "00:11:22:33:44:55"; |
+const char FakeBluetoothDeviceClient::kPairedDeviceName[] = |
+ "Fake Device"; |
+const uint32 FakeBluetoothDeviceClient::kPairedDeviceClass = 0x000104; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kAppleMousePath( |
+ "/fake/hci0/dev1"); |
+const char FakeBluetoothDeviceClient::kAppleMouseAddress[] = |
+ "28:CF:DA:00:00:00"; |
+const char FakeBluetoothDeviceClient::kAppleMouseName[] = |
+ "Apple Magic Mouse"; |
+const uint32 FakeBluetoothDeviceClient::kAppleMouseClass = 0x002580; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kAppleKeyboardPath( |
+ "/fake/hci0/dev2"); |
+const char FakeBluetoothDeviceClient::kAppleKeyboardAddress[] = |
+ "28:37:37:00:00:00"; |
+const char FakeBluetoothDeviceClient::kAppleKeyboardName[] = |
+ "Apple Wireless Keyboard"; |
+const uint32 FakeBluetoothDeviceClient::kAppleKeyboardClass = 0x002540; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kVanishingDevicePath( |
+ "/fake/hci0/dev3"); |
+const char FakeBluetoothDeviceClient::kVanishingDeviceAddress[] = |
+ "01:02:03:04:05:06"; |
+const char FakeBluetoothDeviceClient::kVanishingDeviceName[] = |
+ "Vanishing Device"; |
+const uint32 FakeBluetoothDeviceClient::kVanishingDeviceClass = 0x000104; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kMicrosoftMousePath( |
+ "/fake/hci0/dev4"); |
+const char FakeBluetoothDeviceClient::kMicrosoftMouseAddress[] = |
+ "7C:ED:8D:00:00:00"; |
+const char FakeBluetoothDeviceClient::kMicrosoftMouseName[] = |
+ "Microsoft Mouse"; |
+const uint32 FakeBluetoothDeviceClient::kMicrosoftMouseClass = 0x002540; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kMotorolaKeyboardPath( |
+ "/fake/hci0/dev5"); |
+const char FakeBluetoothDeviceClient::kMotorolaKeyboardAddress[] = |
+ "00:0F:F6:00:00:00"; |
+const char FakeBluetoothDeviceClient::kMotorolaKeyboardName[] = |
+ "Motorola Keyboard"; |
+const uint32 FakeBluetoothDeviceClient::kMotorolaKeyboardClass = 0x002580; |
+ |
+const dbus::ObjectPath FakeBluetoothDeviceClient::kPhonePath( |
+ "/fake/hci0/dev6"); |
+const char FakeBluetoothDeviceClient::kPhoneAddress[] = |
+ "20:7D:74:00:00:00"; |
+const char FakeBluetoothDeviceClient::kPhoneName[] = |
+ "Phone"; |
+const uint32 FakeBluetoothDeviceClient::kPhoneClass = 0x7a020c; |
+ |
+FakeBluetoothDeviceClient::Properties::Properties( |
+ const PropertyChangedCallback& callback) |
+ : ExperimentalBluetoothDeviceClient::Properties( |
+ NULL, |
+ bluetooth_device::kExperimentalBluetoothDeviceInterface, |
+ callback) { |
+} |
+ |
+FakeBluetoothDeviceClient::Properties::~Properties() { |
+} |
+ |
+void FakeBluetoothDeviceClient::Properties::Get( |
+ dbus::PropertyBase* property, |
+ dbus::PropertySet::GetCallback callback) { |
+ VLOG(1) << "Get " << property->name(); |
+ callback.Run(false); |
+} |
+ |
+void FakeBluetoothDeviceClient::Properties::GetAll() { |
+ VLOG(1) << "GetAll"; |
+} |
+ |
+void FakeBluetoothDeviceClient::Properties::Set( |
+ dbus::PropertyBase *property, |
+ dbus::PropertySet::SetCallback callback) { |
+ VLOG(1) << "Set " << property->name(); |
+ if (property->name() == trusted.name()) { |
+ callback.Run(true); |
+ property->ReplaceValueWithSetValue(); |
+ NotifyPropertyChanged(property->name()); |
+ } else { |
+ callback.Run(false); |
+ } |
+} |
+ |
+ |
+FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() |
+ : simulation_interval_ms_(kSimulationIntervalMs), |
+ discovery_simulation_step_(0) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kPairedDevicePath)); |
+ properties->address.ReplaceValue(kPairedDeviceAddress); |
+ properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); |
+ properties->name.ReplaceValue("Fake Device (Name)"); |
+ properties->alias.ReplaceValue(kPairedDeviceName); |
+ properties->paired.ReplaceValue(true); |
+ properties->trusted.ReplaceValue(true); |
+ properties->adapter.ReplaceValue(FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ std::vector<std::string> uuids; |
+ uuids.push_back("00001800-0000-1000-8000-00805f9b34fb"); |
+ uuids.push_back("00001801-0000-1000-8000-00805f9b34fb"); |
+ properties->uuids.ReplaceValue(uuids); |
+ |
+ properties_map_[kPairedDevicePath] = properties; |
+ device_list_.push_back(kPairedDevicePath); |
+} |
+ |
+FakeBluetoothDeviceClient::~FakeBluetoothDeviceClient() { |
+ // Clean up Properties structures |
+ STLDeleteValues(&properties_map_); |
+} |
+ |
+void FakeBluetoothDeviceClient::AddObserver(Observer* observer) { |
+ observers_.AddObserver(observer); |
+} |
+ |
+void FakeBluetoothDeviceClient::RemoveObserver(Observer* observer) { |
+ observers_.RemoveObserver(observer); |
+} |
+ |
+std::vector<dbus::ObjectPath> FakeBluetoothDeviceClient::GetDevicesForAdapter( |
+ const dbus::ObjectPath& adapter_path) { |
+ if (adapter_path == FakeBluetoothAdapterClient::kAdapterPath) |
+ return device_list_; |
+ else |
+ return std::vector<dbus::ObjectPath>(); |
+} |
+ |
+FakeBluetoothDeviceClient::Properties* |
+FakeBluetoothDeviceClient::GetProperties(const dbus::ObjectPath& object_path) { |
+ PropertiesMap::iterator iter = properties_map_.find(object_path); |
+ if (iter != properties_map_.end()) |
+ return iter->second; |
+ return NULL; |
+} |
+ |
+void FakeBluetoothDeviceClient::Connect( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "Connect: " << object_path.value(); |
+ Properties* properties = GetProperties(object_path); |
+ |
+ if (properties->connected.value() == true) { |
+ // Already connected. |
+ callback.Run(); |
+ return; |
+ } |
+ |
+ if (properties->paired.value() != true && |
+ object_path != kMicrosoftMousePath) { |
+ // Must be paired. |
+ error_callback.Run(bluetooth_adapter::kErrorFailed, "Not paired"); |
+ return; |
+ } |
+ |
+ // The device can be connected. |
+ properties->connected.ReplaceValue(true); |
+ |
+ callback.Run(); |
+ properties->NotifyPropertyChanged(properties->connected.name()); |
+} |
+ |
+void FakeBluetoothDeviceClient::Disconnect( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "Disconnect: " << object_path.value(); |
+ error_callback.Run(kNoResponseError, ""); |
+} |
+ |
+void FakeBluetoothDeviceClient::ConnectProfile( |
+ const dbus::ObjectPath& object_path, |
+ const std::string& uuid, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "ConnectProfile: " << object_path.value() << " " << uuid; |
+ error_callback.Run(kNoResponseError, ""); |
+} |
+ |
+void FakeBluetoothDeviceClient::DisconnectProfile( |
+ const dbus::ObjectPath& object_path, |
+ const std::string& uuid, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "DisconnectProfile: " << object_path.value() << " " << uuid; |
+ error_callback.Run(kNoResponseError, ""); |
+} |
+ |
+void FakeBluetoothDeviceClient::Pair( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "Pair: " << object_path.value(); |
+ Properties* properties = GetProperties(object_path); |
+ |
+ if (properties->paired.value() == true) { |
+ // Already paired. |
+ callback.Run(); |
+ return; |
+ } |
+ |
+ FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = |
+ static_cast<FakeBluetoothAgentManagerClient*>( |
+ DBusThreadManager::Get()-> |
+ GetExperimentalBluetoothAgentManagerClient()); |
+ FakeBluetoothAgentServiceProvider* agent_service_provider = |
+ fake_bluetooth_agent_manager_client->GetAgentServiceProvider(); |
+ if (agent_service_provider == NULL) { |
+ error_callback.Run(kNoResponseError, "Missing agent"); |
+ return; |
+ } |
+ |
+ if (object_path == kAppleMousePath) { |
+ // No need to call anything on the pairing delegate, just wait 3 times |
+ // the interval before acting as if the other end accepted it. |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::CompletePairing, |
+ base::Unretained(this), |
+ object_path, callback, error_callback), |
+ base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
+ |
+ } else if (object_path == kAppleKeyboardPath) { |
+ // Display a Pincode, and wait 7 times the interval before acting as |
+ // if the other end accepted it. |
+ agent_service_provider->DisplayPinCode(object_path, "123456"); |
+ |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::CompletePairing, |
+ base::Unretained(this), |
+ object_path, callback, error_callback), |
+ base::TimeDelta::FromMilliseconds(7 * simulation_interval_ms_)); |
+ |
+ } else if (object_path == kMotorolaKeyboardPath) { |
+ // Request a Pincode. |
+ agent_service_provider->RequestPinCode( |
+ object_path, |
+ base::Bind(&FakeBluetoothDeviceClient::PinCodeCallback, |
+ base::Unretained(this), |
+ object_path, |
+ callback, |
+ error_callback)); |
+ |
+ } else if (object_path == kPhonePath) { |
+ // Request confirmation of a Passkey. |
+ agent_service_provider->RequestConfirmation( |
+ object_path, 123456, |
+ base::Bind(&FakeBluetoothDeviceClient::ConfirmationCallback, |
+ base::Unretained(this), |
+ object_path, |
+ callback, |
+ error_callback)); |
+ |
+ } else { |
+ error_callback.Run(kNoResponseError, "No pairing fake"); |
+ } |
+ |
+ // TODO(keybuk): no example of |
+ // RequestPasskey |
+ // DisplayPasskey |
+ |
+} |
+ |
+void FakeBluetoothDeviceClient::CompletePairing( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "CompletePairing: " << object_path.value(); |
+ Properties* properties = GetProperties(object_path); |
+ |
+ properties->paired.ReplaceValue(true); |
+ |
+ callback.Run(); |
+ properties->NotifyPropertyChanged(properties->paired.name()); |
+} |
+ |
+void FakeBluetoothDeviceClient::PinCodeCallback( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback, |
+ ExperimentalBluetoothAgentServiceProvider::Delegate::Status status, |
+ const std::string& pincode) { |
+ VLOG(1) << "PinCodeCallback: " << object_path.value(); |
+ |
+ if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::CompletePairing, |
+ base::Unretained(this), |
+ object_path, callback, error_callback), |
+ base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
+ } |
+} |
+ |
+void FakeBluetoothDeviceClient::ConfirmationCallback( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback, |
+ ExperimentalBluetoothAgentServiceProvider::Delegate::Status status) { |
+ VLOG(1) << "ConfirmationCallback: " << object_path.value(); |
+ |
+ if (status == ExperimentalBluetoothAgentServiceProvider::Delegate::SUCCESS) { |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::CompletePairing, |
+ base::Unretained(this), |
+ object_path, callback, error_callback), |
+ base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_)); |
+ } |
+} |
+ |
+ |
+void FakeBluetoothDeviceClient::CancelPairing( |
+ const dbus::ObjectPath& object_path, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) { |
+ VLOG(1) << "CancelPairing: " << object_path.value(); |
+ error_callback.Run(kNoResponseError, ""); |
+} |
+ |
+ |
+void FakeBluetoothDeviceClient::BeginDiscoverySimulation( |
+ const dbus::ObjectPath& adapter_path) { |
+ VLOG(1) << "starting discovery simulation"; |
+ |
+ discovery_simulation_step_ = 1; |
+ |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, |
+ base::Unretained(this)), |
+ base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
+} |
+ |
+void FakeBluetoothDeviceClient::EndDiscoverySimulation( |
+ const dbus::ObjectPath& adapter_path) { |
+ VLOG(1) << "stopping discovery simulation"; |
+ discovery_simulation_step_ = 0; |
+} |
+ |
+void FakeBluetoothDeviceClient::SetSimulationIntervalMs(int interval_ms) { |
+ simulation_interval_ms_ = interval_ms; |
+} |
+ |
+void FakeBluetoothDeviceClient::RemoveDevice( |
+ const dbus::ObjectPath& adapter_path, |
+ const dbus::ObjectPath& device_path) { |
+ std::vector<dbus::ObjectPath>::iterator listiter = |
+ std::find(device_list_.begin(), device_list_.end(), device_path); |
+ if (listiter == device_list_.end()) |
+ return; |
+ |
+ PropertiesMap::iterator iter = properties_map_.find(device_path); |
+ Properties* properties = iter->second; |
+ |
+ VLOG(1) << "removing device: " << properties->alias.value(); |
+ device_list_.erase(listiter); |
+ |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceRemoved(device_path)); |
+ |
+ delete properties; |
+ properties_map_.erase(iter); |
+} |
+ |
+void FakeBluetoothDeviceClient::OnPropertyChanged( |
+ const dbus::ObjectPath& object_path, |
+ const std::string& property_name) { |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DevicePropertyChanged(object_path, property_name)); |
+} |
+ |
+void FakeBluetoothDeviceClient::DiscoverySimulationTimer() { |
+ if (!discovery_simulation_step_) |
+ return; |
+ |
+ // Timer fires every .75s, the numbers below are arbitrary to give a feel |
+ // for a discovery process. |
+ VLOG(1) << "discovery simulation, step " << discovery_simulation_step_; |
+ if (discovery_simulation_step_ == 2) { |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kAppleMousePath) == device_list_.end()) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kAppleMousePath)); |
+ properties->address.ReplaceValue(kAppleMouseAddress); |
+ properties->bluetooth_class.ReplaceValue(kAppleMouseClass); |
+ properties->name.ReplaceValue("Fake Apple Magic Mouse"); |
+ properties->alias.ReplaceValue(kAppleMouseName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kAppleMousePath] = properties; |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kAppleMousePath)); |
+ } |
+ |
+ } else if (discovery_simulation_step_ == 4) { |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kAppleKeyboardPath) == device_list_.end()) { |
+ Properties *properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kAppleKeyboardPath)); |
+ properties->address.ReplaceValue(kAppleKeyboardAddress); |
+ properties->bluetooth_class.ReplaceValue(kAppleKeyboardClass); |
+ properties->name.ReplaceValue("Fake Apple Wireless Keyboard"); |
+ properties->alias.ReplaceValue(kAppleKeyboardName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kAppleKeyboardPath] = properties; |
+ device_list_.push_back(kAppleKeyboardPath); |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kAppleKeyboardPath)); |
+ } |
+ |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kVanishingDevicePath) == device_list_.end()) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kVanishingDevicePath)); |
+ properties->address.ReplaceValue(kVanishingDeviceAddress); |
+ properties->bluetooth_class.ReplaceValue(kVanishingDeviceClass); |
+ properties->name.ReplaceValue("Fake Vanishing Device"); |
+ properties->alias.ReplaceValue(kVanishingDeviceName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kVanishingDevicePath] = properties; |
+ device_list_.push_back(kVanishingDevicePath); |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kVanishingDevicePath)); |
+ } |
+ |
+ } else if (discovery_simulation_step_ == 7) { |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kMicrosoftMousePath) == device_list_.end()) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kMicrosoftMousePath)); |
+ properties->address.ReplaceValue(kMicrosoftMouseAddress); |
+ properties->bluetooth_class.ReplaceValue(kMicrosoftMouseClass); |
+ properties->name.ReplaceValue("Fake Microsoft Mouse"); |
+ properties->alias.ReplaceValue(kMicrosoftMouseName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kMicrosoftMousePath] = properties; |
+ device_list_.push_back(kMicrosoftMousePath); |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kMicrosoftMousePath)); |
+ } |
+ |
+ } else if (discovery_simulation_step_ == 8) { |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kMotorolaKeyboardPath) == device_list_.end()) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kMotorolaKeyboardPath)); |
+ properties->address.ReplaceValue(kMotorolaKeyboardAddress); |
+ properties->bluetooth_class.ReplaceValue(kMotorolaKeyboardClass); |
+ properties->name.ReplaceValue("Fake Motorola Keyboard"); |
+ properties->alias.ReplaceValue(kMotorolaKeyboardName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kMotorolaKeyboardPath] = properties; |
+ device_list_.push_back(kMotorolaKeyboardPath); |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kMotorolaKeyboardPath)); |
+ } |
+ |
+ } else if (discovery_simulation_step_ == 10) { |
+ if (std::find(device_list_.begin(), device_list_.end(), |
+ kPhonePath) == device_list_.end()) { |
+ Properties* properties = new Properties(base::Bind( |
+ &FakeBluetoothDeviceClient::OnPropertyChanged, |
+ base::Unretained(this), |
+ kPhonePath)); |
+ properties->address.ReplaceValue(kPhoneAddress); |
+ properties->bluetooth_class.ReplaceValue(kPhoneClass); |
+ properties->name.ReplaceValue("Fake Phone"); |
+ properties->alias.ReplaceValue(kPhoneName); |
+ properties->adapter.ReplaceValue( |
+ FakeBluetoothAdapterClient::kAdapterPath); |
+ |
+ properties_map_[kPhonePath] = properties; |
+ device_list_.push_back(kPhonePath); |
+ FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_, |
+ DeviceAdded(kPhonePath)); |
+ } |
+ |
+ } else if (discovery_simulation_step_ == 13) { |
+ RemoveDevice(FakeBluetoothAdapterClient::kAdapterPath, |
+ kVanishingDevicePath); |
+ |
+ } else if (discovery_simulation_step_ == 14) { |
+ return; |
+ |
+ } |
+ |
+ ++discovery_simulation_step_; |
+ MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&FakeBluetoothDeviceClient::DiscoverySimulationTimer, |
+ base::Unretained(this)), |
+ base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); |
+} |
+ |
+} // namespace chromeos |