buffet: Fix state update notification to GCD cloud server
Device state notification from buffet's state manager are coming
with state property names in form "package_name.property_name" and
that's how they were reported to the GCD server instead of being
split in JSON as {"package_name": {"property_name": value}}.
Also added "buffet_client GetState" command to retrieve actual
internal device state from buffet bypassing the GCD server-dependent
GetDeviceInfo. This is useful for debugging and also in case of
local-only workflow (with no GCD server present).
Finally, modified "buffet_client UpdateState" to allow complex
non-string state properties to be set. Now this command expects
a property name followed by a properly formed json value for the
property. Strings now require double-quotes. Integers, Booleans,
lists and dictionaries can now be set too.
BUG=chromium:449250
TEST=FEATURES=test USE=examples emerge-link buffet
Deployed and tested on device
Change-Id: Id2c97b422c56ec6648994ab37bb47284a6fb2041
Reviewed-on: https://chromium-review.googlesource.com/241955
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Anton Muhin <antonm@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 171eeac..04fcc36 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -155,6 +155,14 @@
response->Return();
}
+bool Manager::GetState(chromeos::ErrorPtr* error, std::string* state) {
+ auto json = state_manager_->GetStateValuesAsJson(error);
+ if (!json)
+ return false;
+ base::JSONWriter::Write(json.get(), state);
+ return true;
+}
+
void Manager::AddCommand(DBusMethodResponse<> response,
const std::string& json_command) {
static int next_id = 0;