Add {Get,Set}CohortHint interface.
Export the "cohort hint" getter and setter in the client interfaces
(D-Bus and Binder). The cohort hint is sent to Omaha on every update
check request but can be ignored and/or reset by Omaha on every
response.
Other minor linter fixes to the affected files.
Bug: 31740109
Test: Build with D-Bus and with Binder.
Change-Id: I93214f6ffb8662c238b3351e52bf2bdf23e46a9c
diff --git a/client_library/client_binder.cc b/client_library/client_binder.cc
index 6a61722..e98c225 100644
--- a/client_library/client_binder.cc
+++ b/client_library/client_binder.cc
@@ -73,6 +73,20 @@
return true;
}
+bool BinderUpdateEngineClient::SetCohortHint(const string& in_cohort_hint) {
+ return service_->SetCohortHint(String16{in_cohort_hint.c_str()}).isOk();
+}
+
+bool BinderUpdateEngineClient::GetCohortHint(string* out_cohort_hint) const {
+ String16 out_as_string16;
+
+ if (!service_->GetCohortHint(&out_as_string16).isOk())
+ return false;
+
+ *out_cohort_hint = String8{out_as_string16}.string();
+ return true;
+}
+
bool BinderUpdateEngineClient::SetUpdateOverCellularPermission(bool allowed) {
return service_->SetUpdateOverCellularPermission(allowed).isOk();
}
diff --git a/client_library/client_binder.h b/client_library/client_binder.h
index cd857e0..b1b34da 100644
--- a/client_library/client_binder.h
+++ b/client_library/client_binder.h
@@ -53,6 +53,9 @@
std::string* out_new_version,
int64_t* out_new_size) const override;
+ bool SetCohortHint(const std::string& in_cohort_hint) override;
+ bool GetCohortHint(std::string* out_cohort_hint) const override;
+
bool SetUpdateOverCellularPermission(bool allowed) override;
bool GetUpdateOverCellularPermission(bool* allowed) const override;
diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc
index 5cb63a4..426412c 100644
--- a/client_library/client_dbus.cc
+++ b/client_library/client_dbus.cc
@@ -72,6 +72,14 @@
return StringToUpdateStatus(status_as_string, out_update_status);
}
+bool DBusUpdateEngineClient::SetCohortHint(const string& cohort_hint) {
+ return proxy_->SetCohortHint(cohort_hint, nullptr);
+}
+
+bool DBusUpdateEngineClient::GetCohortHint(string* cohort_hint) const {
+ return proxy_->GetCohortHint(cohort_hint, nullptr);
+}
+
bool DBusUpdateEngineClient::SetUpdateOverCellularPermission(bool allowed) {
return proxy_->SetUpdateOverCellularPermission(allowed, nullptr);
}
diff --git a/client_library/client_dbus.h b/client_library/client_dbus.h
index a2de594..cec1665 100644
--- a/client_library/client_dbus.h
+++ b/client_library/client_dbus.h
@@ -47,6 +47,9 @@
std::string* out_new_version,
int64_t* out_new_size) const override;
+ bool SetCohortHint(const std::string& cohort_hint) override;
+ bool GetCohortHint(std::string* cohort_hint) const override;
+
bool SetUpdateOverCellularPermission(bool allowed) override;
bool GetUpdateOverCellularPermission(bool* allowed) const override;
diff --git a/client_library/include/update_engine/client.h b/client_library/include/update_engine/client.h
index 7956dbd..be87c76 100644
--- a/client_library/include/update_engine/client.h
+++ b/client_library/include/update_engine/client.h
@@ -67,6 +67,10 @@
std::string* out_new_version,
int64_t* out_new_size) const = 0;
+ // Getter and setter for the cohort hint.
+ virtual bool SetCohortHint(const std::string& cohort_hint) = 0;
+ virtual bool GetCohortHint(std::string* cohort_hint) const = 0;
+
// Getter and setter for the updates over cellular connections.
virtual bool SetUpdateOverCellularPermission(bool allowed) = 0;
virtual bool GetUpdateOverCellularPermission(bool* allowed) const = 0;