Commit 2badb80a authored by Alex Chau's avatar Alex Chau Committed by Commit Bot

Avoid renaming of fully synced devices in SharingUtils

- We only want to apply renaming for sign-in only devices, which has
  client_name == model
- Android and Chrome OS also has client_name == model, so  we should
  avoid renaming them

Bug: 1024864
Change-Id: If7ab84308a3f76cf24c32982462703c8eed0aeb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917759
Commit-Queue: Alex Chau <alexchau@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715671}
parent 57f83091
......@@ -154,11 +154,11 @@ TEST_F(SharingDeviceSourceSyncTest, GetAllDevices_Deduplicated) {
// Add two devices with the same hardware info.
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
auto device_info_3 =
CreateDeviceInfo("client_name_2", {"manufacturer 1", "model 1"});
CreateDeviceInfo("model 1", {"manufacturer 1", "model 1"});
fake_device_info_tracker_.Add(device_info_3.get());
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
auto device_info_4 =
CreateDeviceInfo("client_name_3", {"manufacturer 1", "model 1"});
CreateDeviceInfo("model 1", {"manufacturer 1", "model 1"});
fake_device_info_tracker_.Add(device_info_4.get());
// Add a device with the same info as the local device.
......@@ -188,15 +188,18 @@ TEST_F(SharingDeviceSourceSyncTest, GetAllDevices_DeviceNaming) {
fake_device_info_tracker_.Add(device_info_1.get());
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
auto device_info_2 = CreateDeviceInfo("name", {"manufacturer 1", "model 1"});
auto device_info_2 =
CreateDeviceInfo("model 1", {"manufacturer 1", "model 1"});
fake_device_info_tracker_.Add(device_info_2.get());
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
auto device_info_3 = CreateDeviceInfo("name", {"manufacturer 1", "model 2"});
auto device_info_3 =
CreateDeviceInfo("model 2", {"manufacturer 1", "model 2"});
fake_device_info_tracker_.Add(device_info_3.get());
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
auto device_info_4 = CreateDeviceInfo("name", {"manufacturer 2", "model 1"});
auto device_info_4 =
CreateDeviceInfo("model 1", {"manufacturer 2", "model 1"});
fake_device_info_tracker_.Add(device_info_4.get());
auto devices = device_source->GetAllDevices();
......
......@@ -72,16 +72,21 @@ SharingDeviceNames GetSharingDeviceNames(const syncer::DeviceInfo* device) {
SharingDeviceNames device_names;
base::SysInfo::HardwareInfo hardware_info = device->hardware_info();
hardware_info.manufacturer = CapitalizeWords(hardware_info.manufacturer);
// The model might be empty if other device is still on M78 or lower with sync
// turned on.
if (hardware_info.model.empty()) {
sync_pb::SyncEnums::DeviceType type = device->device_type();
// We only want to apply renaming for sign-in only devices. sign-in only
// devices has client_name == model. Additionally, Android and Chrome OS also
// uses model as client_name, so we should avoid renaming them as well.
// Lastly, avoid renaming if HardwareInfo is not available for M78- devices,
if (hardware_info.model.empty() ||
hardware_info.model != device->client_name() ||
type == sync_pb::SyncEnums::TYPE_CROS ||
type == sync_pb::SyncEnums::TYPE_PHONE ||
type == sync_pb::SyncEnums::TYPE_TABLET) {
device_names.full_name = device_names.short_name = device->client_name();
return device_names;
}
sync_pb::SyncEnums::DeviceType type = device->device_type();
hardware_info.manufacturer = CapitalizeWords(hardware_info.manufacturer);
// For chromeOS, return manufacturer + model.
if (type == sync_pb::SyncEnums::TYPE_CROS) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment