buffet: Deprecate "displayName" in favor of "name" in device resource
GCD spec deprecated "displayName" and "systemName" and now requires
to use just "name" in device resource. Make the corresponding change
to buffet to match the spec.
BUG=brillo:778
TEST=`FEATURES=test emerge-link buffet`
`test_that -b link --fast 100.96.48.244 e:buffet_.*`
CQ-DEPEND=CL:264751
Change-Id: Iffc7d2ac2d5fa57282e607ff801f0d4b04e58e28
Reviewed-on: https://chromium-review.googlesource.com/264577
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/buffet_config.cc b/buffet/buffet_config.cc
index e4f6209..1ed7842 100644
--- a/buffet/buffet_config.cc
+++ b/buffet/buffet_config.cc
@@ -17,7 +17,6 @@
const char kServiceURL[] = "service_url";
const char kDeviceKind[] = "device_kind";
const char kName[] = "name";
-const char kDefaultDisplayName[] = "default_display_name";
const char kDefaultDescription[] = "default_description";
const char kDefaultLocation[] = "default_location";
const char kModelId[] = "model_id";
@@ -40,7 +39,6 @@
store.GetString(config_keys::kServiceURL, &service_url_);
store.GetString(config_keys::kDeviceKind, &device_kind_);
store.GetString(config_keys::kName, &name_);
- store.GetString(config_keys::kDefaultDisplayName, &default_display_name_);
store.GetString(config_keys::kDefaultDescription, &default_description_);
store.GetString(config_keys::kDefaultLocation, &default_location_);
store.GetString(config_keys::kModelId, &model_id_);
diff --git a/buffet/buffet_config.h b/buffet/buffet_config.h
index 550f0da..af6c849 100644
--- a/buffet/buffet_config.h
+++ b/buffet/buffet_config.h
@@ -26,7 +26,6 @@
std::string service_url() const { return service_url_; }
std::string device_kind() const { return device_kind_; }
std::string name() const { return name_; }
- std::string default_display_name() const { return default_display_name_; }
std::string default_description() const { return default_description_; }
std::string default_location() const { return default_location_; }
std::string model_id() const { return model_id_; }
@@ -39,8 +38,7 @@
std::string oauth_url_{"https://accounts.google.com/o/oauth2/"};
std::string service_url_{"https://www.googleapis.com/clouddevices/v1/"};
std::string device_kind_{"vendor"};
- std::string name_{"developer_device"};
- std::string default_display_name_{"Developer device"};
+ std::string name_{"Developer device"};
std::string default_description_{"A development device"};
std::string default_location_{"my desk"};
std::string model_id_{"AAA"};
diff --git a/buffet/device_registration_info.cc b/buffet/device_registration_info.cc
index a87436d..c9da52b 100644
--- a/buffet/device_registration_info.cc
+++ b/buffet/device_registration_info.cc
@@ -39,7 +39,7 @@
const char kRefreshToken[] = "refresh_token";
const char kDeviceId[] = "device_id";
const char kRobotAccount[] = "robot_account";
-const char kDisplayName[] = "display_name";
+const char kName[] = "name";
const char kDescription[] = "description";
const char kLocation[] = "location";
@@ -183,20 +183,20 @@
std::string refresh_token;
std::string device_id;
std::string device_robot_account;
- std::string display_name;
+ std::string name;
std::string description;
std::string location;
if (!dict->GetString(storage_keys::kRefreshToken, &refresh_token) ||
!dict->GetString(storage_keys::kDeviceId, &device_id) ||
!dict->GetString(storage_keys::kRobotAccount, &device_robot_account) ||
- !dict->GetString(storage_keys::kDisplayName, &display_name) ||
+ !dict->GetString(storage_keys::kName, &name) ||
!dict->GetString(storage_keys::kDescription, &description) ||
!dict->GetString(storage_keys::kLocation, &location)) {
return false;
}
refresh_token_ = refresh_token;
device_robot_account_ = device_robot_account;
- display_name_ = display_name;
+ name_ = name;
description_ = description;
location_ = location;
@@ -220,7 +220,7 @@
dict.SetString(storage_keys::kRefreshToken, refresh_token_);
dict.SetString(storage_keys::kDeviceId, device_id_);
dict.SetString(storage_keys::kRobotAccount, device_robot_account_);
- dict.SetString(storage_keys::kDisplayName, display_name_);
+ dict.SetString(storage_keys::kName, name_);
dict.SetString(storage_keys::kDescription, description_);
dict.SetString(storage_keys::kLocation, location_);
@@ -401,9 +401,7 @@
if (!device_id_.empty())
resource->SetString("id", device_id_);
resource->SetString("deviceKind", config_->device_kind());
- resource->SetString("name", config_->name());
- if (!display_name_.empty())
- resource->SetString("displayName", display_name_);
+ resource->SetString("name", name_.empty() ? config_->name() : name_);
if (!description_.empty())
resource->SetString("description", description_);
if (!location_.empty())
@@ -468,8 +466,7 @@
}
// These fields are optional, and will default to values from the manufacturer
// supplied config.
- GetWithDefault(params, storage_keys::kDisplayName,
- config_->default_display_name(), &display_name_);
+ GetWithDefault(params, storage_keys::kName, config_->name(), &name_);
GetWithDefault(params, storage_keys::kDescription,
config_->default_description(), &description_);
GetWithDefault(params, storage_keys::kLocation,
diff --git a/buffet/device_registration_info.h b/buffet/device_registration_info.h
index 52b520a..389042b 100644
--- a/buffet/device_registration_info.h
+++ b/buffet/device_registration_info.h
@@ -216,7 +216,7 @@
std::string device_robot_account_;
// These fields are user settable and stored in the state store.
- std::string display_name_;
+ std::string name_;
std::string description_;
std::string location_;
diff --git a/buffet/device_registration_info_unittest.cc b/buffet/device_registration_info_unittest.cc
index 6136eeb..e3fb737 100644
--- a/buffet/device_registration_info_unittest.cc
+++ b/buffet/device_registration_info_unittest.cc
@@ -63,7 +63,7 @@
data->SetString(storage_keys::kRefreshToken, "");
data->SetString(storage_keys::kDeviceId, "");
data->SetString(storage_keys::kRobotAccount, "");
- data->SetString(storage_keys::kDisplayName, "");
+ data->SetString(storage_keys::kName, "");
data->SetString(storage_keys::kDescription, "");
data->SetString(storage_keys::kLocation, "");
}
@@ -200,8 +200,7 @@
config_store.SetString("client_secret", test_data::kClientSecret);
config_store.SetString("api_key", test_data::kApiKey);
config_store.SetString("device_kind", "vendor");
- config_store.SetString("name", "coffee_pot");
- config_store.SetString("default_display_name", "Coffee Pot");
+ config_store.SetString("name", "Coffee Pot");
config_store.SetString("default_description", "Easy to clean");
config_store.SetString("default_location", "Kitchen");
config_store.SetString("model_id", "AAA");
@@ -257,7 +256,7 @@
data.SetString(storage_keys::kRefreshToken, "d");
data.SetString(storage_keys::kDeviceId, "e");
data.SetString(storage_keys::kRobotAccount, "h");
- data.SetString(storage_keys::kDisplayName, "k");
+ data.SetString(storage_keys::kName, "k");
data.SetString(storage_keys::kDescription, "l");
data.SetString(storage_keys::kLocation, "m");
@@ -404,7 +403,7 @@
EXPECT_EQ("Kitchen", value);
EXPECT_TRUE(json->GetString("deviceDraft.modelManifestId", &value));
EXPECT_EQ("AAA", value);
- EXPECT_TRUE(json->GetString("deviceDraft.displayName", &value));
+ EXPECT_TRUE(json->GetString("deviceDraft.name", &value));
EXPECT_EQ("Coffee Pot", value);
base::DictionaryValue* commandDefs = nullptr;
EXPECT_TRUE(json->GetDictionary("deviceDraft.commandDefs", &commandDefs));
diff --git a/buffet/device_registration_storage_keys.h b/buffet/device_registration_storage_keys.h
index 73ddec1..18323f0 100644
--- a/buffet/device_registration_storage_keys.h
+++ b/buffet/device_registration_storage_keys.h
@@ -14,7 +14,7 @@
extern const char kRefreshToken[];
extern const char kDeviceId[];
extern const char kRobotAccount[];
-extern const char kDisplayName[];
+extern const char kName[];
extern const char kDescription[];
extern const char kLocation[];