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 4d8679750a495dcd9d3b928c4c51bc87eb4ec664..4b5395ae7af2d4bdcb7772c6f867a383c37a9c40 100644 |
--- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc |
+++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc |
@@ -315,6 +315,7 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() |
properties->address.ReplaceValue(kPairedDeviceAddress); |
properties->bluetooth_class.ReplaceValue(kPairedDeviceClass); |
properties->name.ReplaceValue(kPairedDeviceName); |
+ properties->name.set_valid(true); |
properties->alias.ReplaceValue(kPairedDeviceAlias); |
properties->paired.ReplaceValue(true); |
properties->trusted.ReplaceValue(true); |
@@ -338,6 +339,7 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient() |
properties->address.ReplaceValue(kPairedUnconnectableDeviceAddress); |
properties->bluetooth_class.ReplaceValue(kPairedUnconnectableDeviceClass); |
properties->name.ReplaceValue(kPairedUnconnectableDeviceName); |
+ properties->name.set_valid(true); |
properties->alias.ReplaceValue(kPairedUnconnectableDeviceAlias); |
properties->paired.ReplaceValue(true); |
properties->trusted.ReplaceValue(true); |
@@ -658,8 +660,8 @@ void FakeBluetoothDeviceClient::CreateDevice( |
if (device_path == dbus::ObjectPath(kLegacyAutopairPath)) { |
properties->address.ReplaceValue(kLegacyAutopairAddress); |
properties->bluetooth_class.ReplaceValue(kLegacyAutopairClass); |
- properties->name.ReplaceValue("LegacyAutopair"); |
- properties->alias.ReplaceValue(kLegacyAutopairName); |
+ properties->name.ReplaceValue(kLegacyAutopairName); |
+ properties->name.set_valid(true); |
std::vector<std::string> uuids; |
uuids.push_back("00001124-0000-1000-8000-00805f9b34fb"); |
@@ -668,8 +670,8 @@ void FakeBluetoothDeviceClient::CreateDevice( |
} else if (device_path == dbus::ObjectPath(kDisplayPinCodePath)) { |
properties->address.ReplaceValue(kDisplayPinCodeAddress); |
properties->bluetooth_class.ReplaceValue(kDisplayPinCodeClass); |
- properties->name.ReplaceValue("DisplayPinCode"); |
- properties->alias.ReplaceValue(kDisplayPinCodeName); |
+ properties->name.ReplaceValue(kDisplayPinCodeName); |
+ properties->name.set_valid(true); |
std::vector<std::string> uuids; |
uuids.push_back("00001124-0000-1000-8000-00805f9b34fb"); |
@@ -678,14 +680,14 @@ void FakeBluetoothDeviceClient::CreateDevice( |
} else if (device_path == dbus::ObjectPath(kVanishingDevicePath)) { |
properties->address.ReplaceValue(kVanishingDeviceAddress); |
properties->bluetooth_class.ReplaceValue(kVanishingDeviceClass); |
- properties->name.ReplaceValue("VanishingDevice"); |
- properties->alias.ReplaceValue(kVanishingDeviceName); |
+ properties->name.ReplaceValue(kVanishingDeviceName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kConnectUnpairablePath)) { |
properties->address.ReplaceValue(kConnectUnpairableAddress); |
properties->bluetooth_class.ReplaceValue(kConnectUnpairableClass); |
- properties->name.ReplaceValue("ConnectUnpairable"); |
- properties->alias.ReplaceValue(kConnectUnpairableName); |
+ properties->name.ReplaceValue(kConnectUnpairableName); |
+ properties->name.set_valid(true); |
std::vector<std::string> uuids; |
uuids.push_back("00001124-0000-1000-8000-00805f9b34fb"); |
@@ -694,8 +696,8 @@ void FakeBluetoothDeviceClient::CreateDevice( |
} else if (device_path == dbus::ObjectPath(kDisplayPasskeyPath)) { |
properties->address.ReplaceValue(kDisplayPasskeyAddress); |
properties->bluetooth_class.ReplaceValue(kDisplayPasskeyClass); |
- properties->name.ReplaceValue("DisplayPasskey"); |
- properties->alias.ReplaceValue(kDisplayPasskeyName); |
+ properties->name.ReplaceValue(kDisplayPasskeyName); |
+ properties->name.set_valid(true); |
std::vector<std::string> uuids; |
uuids.push_back("00001124-0000-1000-8000-00805f9b34fb"); |
@@ -704,44 +706,44 @@ void FakeBluetoothDeviceClient::CreateDevice( |
} else if (device_path == dbus::ObjectPath(kRequestPinCodePath)) { |
properties->address.ReplaceValue(kRequestPinCodeAddress); |
properties->bluetooth_class.ReplaceValue(kRequestPinCodeClass); |
- properties->name.ReplaceValue("RequestPinCode"); |
- properties->alias.ReplaceValue(kRequestPinCodeName); |
+ properties->name.ReplaceValue(kRequestPinCodeName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kConfirmPasskeyPath)) { |
properties->address.ReplaceValue(kConfirmPasskeyAddress); |
properties->bluetooth_class.ReplaceValue(kConfirmPasskeyClass); |
- properties->name.ReplaceValue("ConfirmPasskey"); |
- properties->alias.ReplaceValue(kConfirmPasskeyName); |
+ properties->name.ReplaceValue(kConfirmPasskeyName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kRequestPasskeyPath)) { |
properties->address.ReplaceValue(kRequestPasskeyAddress); |
properties->bluetooth_class.ReplaceValue(kRequestPasskeyClass); |
- properties->name.ReplaceValue("RequestPasskey"); |
- properties->alias.ReplaceValue(kRequestPasskeyName); |
+ properties->name.ReplaceValue(kRequestPasskeyName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kUnconnectableDevicePath)) { |
properties->address.ReplaceValue(kUnconnectableDeviceAddress); |
properties->bluetooth_class.ReplaceValue(kUnconnectableDeviceClass); |
- properties->name.ReplaceValue("UnconnectableDevice"); |
- properties->alias.ReplaceValue(kUnconnectableDeviceName); |
+ properties->name.ReplaceValue(kUnconnectableDeviceName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kUnpairableDevicePath)) { |
properties->address.ReplaceValue(kUnpairableDeviceAddress); |
properties->bluetooth_class.ReplaceValue(kUnpairableDeviceClass); |
- properties->name.ReplaceValue("Fake Unpairable Device"); |
- properties->alias.ReplaceValue(kUnpairableDeviceName); |
+ properties->name.ReplaceValue(kUnpairableDeviceName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kJustWorksPath)) { |
properties->address.ReplaceValue(kJustWorksAddress); |
properties->bluetooth_class.ReplaceValue(kJustWorksClass); |
- properties->name.ReplaceValue("JustWorks"); |
- properties->alias.ReplaceValue(kJustWorksName); |
+ properties->name.ReplaceValue(kJustWorksName); |
+ properties->name.set_valid(true); |
} else if (device_path == dbus::ObjectPath(kLowEnergyPath)) { |
properties->address.ReplaceValue(kLowEnergyAddress); |
properties->bluetooth_class.ReplaceValue(kLowEnergyClass); |
- properties->name.ReplaceValue("Heart Rate Monitor"); |
- properties->alias.ReplaceValue(kLowEnergyName); |
+ properties->name.ReplaceValue(kLowEnergyName); |
+ properties->name.set_valid(true); |
properties->services_resolved.ReplaceValue(false); |
properties->type.ReplaceValue(BluetoothDeviceClient::kTypeLe); |
@@ -756,8 +758,8 @@ void FakeBluetoothDeviceClient::CreateDevice( |
properties->trusted.ReplaceValue(true); |
properties->connected.ReplaceValue(true); |
properties->paired.ReplaceValue(false); |
- properties->name.ReplaceValue("Connected Pairable Device"); |
- properties->alias.ReplaceValue(kConnectedTrustedNotPairedDeviceName); |
+ properties->name.ReplaceValue(kConnectedTrustedNotPairedDeviceName); |
+ properties->name.set_valid(true); |
} else { |
NOTREACHED(); |
} |
@@ -782,6 +784,7 @@ void FakeBluetoothDeviceClient::CreateDeviceWithProperties( |
base::Unretained(this), device_path))); |
properties->adapter.ReplaceValue(adapter_path); |
properties->name.ReplaceValue(props.device_name); |
+ properties->name.set_valid(true); |
properties->alias.ReplaceValue(props.device_alias); |
properties->address.ReplaceValue(props.device_address); |
properties->bluetooth_class.ReplaceValue(props.device_class); |
@@ -1058,7 +1061,7 @@ void FakeBluetoothDeviceClient::RemoveDevice( |
PropertiesMap::const_iterator iter = properties_map_.find(device_path); |
Properties* properties = iter->second.get(); |
- VLOG(1) << "removing device: " << properties->alias.value(); |
+ VLOG(1) << "removing device: " << properties->name.value(); |
device_list_.erase(listiter); |
// Remove the Input interface if it exists. This should be called before the |
@@ -1749,7 +1752,7 @@ void FakeBluetoothDeviceClient::RemoveAllDevices() { |
void FakeBluetoothDeviceClient::CreateTestDevice( |
const dbus::ObjectPath& adapter_path, |
- const std::string name, |
+ const base::Optional<std::string> name, |
const std::string alias, |
const std::string device_address, |
const std::vector<std::string>& service_uuids, |
@@ -1768,7 +1771,10 @@ void FakeBluetoothDeviceClient::CreateTestDevice( |
properties->adapter.ReplaceValue(adapter_path); |
properties->address.ReplaceValue(device_address); |
- properties->name.ReplaceValue(name); |
+ properties->name.ReplaceValue( |
+ name.value_or("Invalid Device Name set in " |
+ "FakeBluetoothDeviceClient::CreateTestDevice")); |
+ properties->name.set_valid(name.has_value()); |
properties->alias.ReplaceValue(alias); |
properties->uuids.ReplaceValue(service_uuids); |