am c3f866f6: Merge "metricsd: Use system properties to store build time metadata."
* commit 'c3f866f60cedc7eade674a7a8eec740dd938264f':
metricsd: Use system properties to store build time metadata.
diff --git a/metricsd/Android.mk b/metricsd/Android.mk
index 9fd8eda..89fa222 100644
--- a/metricsd/Android.mk
+++ b/metricsd/Android.mk
@@ -110,6 +110,7 @@
libprotobuf-cpp-lite \
libchromeos-http \
libchromeos-dbus \
+ libcutils \
libdbus
LOCAL_SRC_FILES := $(metrics_daemon_sources)
LOCAL_STATIC_LIBRARIES := metrics_daemon_protos
diff --git a/metricsd/constants.h b/metricsd/constants.h
index 56dac0d..15c15d9 100644
--- a/metricsd/constants.h
+++ b/metricsd/constants.h
@@ -24,6 +24,11 @@
static const char kMetricsServer[] = "https://clients4.google.com/uma/v2";
static const char kConsentFilePath[] = "/data/misc/metrics/enabled";
static const char kDefaultVersion[] = "0.0.0.0";
+
+// System properties used.
+static const char kBuildTargetIdProperty[] = "ro.product.build_target_id";
+static const char kChannelProperty[] = "ro.product.channel";
+static const char kProductVersionProperty[] = "ro.product.version";
} // namespace metrics
#endif // METRICS_CONSTANTS_H_
diff --git a/metricsd/metrics_daemon.cc b/metricsd/metrics_daemon.cc
index 069f68e..5855cee 100644
--- a/metricsd/metrics_daemon.cc
+++ b/metricsd/metrics_daemon.cc
@@ -32,7 +32,7 @@
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
-#include <base/sys_info.h>
+#include <cutils/properties.h>
#include <dbus/dbus.h>
#include <dbus/message.h>
@@ -209,10 +209,13 @@
if (version_hash_is_cached)
return cached_version_hash;
version_hash_is_cached = true;
- std::string version = metrics::kDefaultVersion;
+
+ char version[PROPERTY_VALUE_MAX];
// The version might not be set for development devices. In this case, use the
// zero version.
- base::SysInfo::GetLsbReleaseValue("BRILLO_VERSION", &version);
+ property_get(metrics::kProductVersionProperty, version,
+ metrics::kDefaultVersion);
+
cached_version_hash = base::Hash(version);
if (testing_) {
cached_version_hash = 42; // return any plausible value for the hash
diff --git a/metricsd/uploader/system_profile_cache.cc b/metricsd/uploader/system_profile_cache.cc
index 7dd0323..21ec229 100644
--- a/metricsd/uploader/system_profile_cache.cc
+++ b/metricsd/uploader/system_profile_cache.cc
@@ -21,7 +21,7 @@
#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
-#include <base/sys_info.h>
+#include <cutils/properties.h>
#include <string>
#include <vector>
@@ -73,21 +73,28 @@
CHECK(!initialized_)
<< "this should be called only once in the metrics_daemon lifetime.";
- if (!base::SysInfo::GetLsbReleaseValue("BRILLO_BUILD_TARGET_ID",
- &profile_.build_target_id)) {
- LOG(ERROR) << "BRILLO_BUILD_TARGET_ID is not set in /etc/lsb-release.";
+ char property_value[PROPERTY_VALUE_MAX];
+ property_get(metrics::kBuildTargetIdProperty, property_value, "");
+ profile_.build_target_id = std::string(property_value);
+
+ if (profile_.build_target_id.empty()) {
+ LOG(ERROR) << "System property " << metrics::kBuildTargetIdProperty
+ << " is not set.";
return false;
}
- std::string channel;
- if (!base::SysInfo::GetLsbReleaseValue("BRILLO_CHANNEL", &channel) ||
- !base::SysInfo::GetLsbReleaseValue("BRILLO_VERSION", &profile_.version)) {
+ property_get(metrics::kChannelProperty, property_value, "");
+ std::string channel(property_value);
+
+ property_get(metrics::kProductVersionProperty, property_value, "");
+ profile_.version = std::string(property_value);
+
+ if (channel.empty() || profile_.version.empty()) {
// If the channel or version is missing, the image is not official.
// In this case, set the channel to unknown and the version to 0.0.0.0 to
// avoid polluting the production data.
channel = "";
profile_.version = metrics::kDefaultVersion;
-
}
profile_.client_id =
testing_ ? "client_id_test" :