summaryrefslogtreecommitdiffstats
path: root/metrics
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2015-02-17 13:54:04 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-18 01:45:37 +0000
commit067ec8ba78287d2992331423d74d978cfa8669ff (patch)
tree394862ff54798a9fe1f8a6dcbbb55f8c2ae202c2 /metrics
parent7e238f3bcb76fe5f311b89881a7bae594963f22e (diff)
downloadcore-067ec8ba78287d2992331423d74d978cfa8669ff.tar.gz
core-067ec8ba78287d2992331423d74d978cfa8669ff.tar.bz2
core-067ec8ba78287d2992331423d74d978cfa8669ff.zip
metrics: Disable uploader on non-official build.
The metrics uploader should only be enabled on an official build. BUG=chromium:459105 TEST=`FEATURES=test emerge-$BOARD metrics` TEST=Verified that metrics uploader is disabled on a developer build. Change-Id: I5cadb3afeb56c0adac971228aa48ad56ed913bbf Reviewed-on: https://chromium-review.googlesource.com/250542 Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org> Commit-Queue: Ben Chan <benchan@chromium.org> Tested-by: Ben Chan <benchan@chromium.org>
Diffstat (limited to 'metrics')
-rw-r--r--metrics/metrics_daemon.cc22
-rw-r--r--metrics/metrics_daemon.h3
2 files changed, 22 insertions, 3 deletions
diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc
index a746e06a0..4a69d8b4c 100644
--- a/metrics/metrics_daemon.cc
+++ b/metrics/metrics_daemon.cc
@@ -48,6 +48,10 @@ const char kCrashReporterUserCrashSignal[] = "UserCrash";
const char kCrashReporterMatchRule[] =
"type='signal',interface='%s',path='/',member='%s'";
+// Build type of an official build.
+// See src/third_party/chromiumos-overlay/chromeos/scripts/cros_set_lsb_release.
+const char kOfficialBuild[] = "Official Build";
+
const int kSecondsPerMinute = 60;
const int kMinutesPerHour = 60;
const int kHoursPerDay = 24;
@@ -209,6 +213,13 @@ uint32_t MetricsDaemon::GetOsVersionHash() {
return cached_version_hash;
}
+bool MetricsDaemon::IsOnOfficialBuild() const {
+ std::string build_type;
+ return (base::SysInfo::GetLsbReleaseValue("CHROMEOS_RELEASE_BUILD_TYPE",
+ &build_type) &&
+ build_type == kOfficialBuild);
+}
+
void MetricsDaemon::Init(bool testing,
bool uploader_active,
MetricsLibraryInterface* metrics_lib,
@@ -327,9 +338,14 @@ int MetricsDaemon::OnInit() {
base::TimeDelta::FromMilliseconds(kUpdateStatsIntervalMs));
if (uploader_active_) {
- LOG(INFO) << "uploader enabled";
- upload_service_.reset(new UploadService(new SystemProfileCache(), server_));
- upload_service_->Init(upload_interval_, metrics_file_);
+ if (IsOnOfficialBuild()) {
+ LOG(INFO) << "uploader enabled";
+ upload_service_.reset(
+ new UploadService(new SystemProfileCache(), server_));
+ upload_service_->Init(upload_interval_, metrics_file_);
+ } else {
+ LOG(INFO) << "uploader disabled on non-official build";
+ }
}
return EX_OK;
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index 397fd2109..d38dcd92d 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -273,6 +273,9 @@ class MetricsDaemon : public chromeos::DBusDaemon {
// to a unsigned 32-bit int.
uint32_t GetOsVersionHash();
+ // Returns true if the system is using an official build.
+ bool IsOnOfficialBuild() const;
+
// Updates stats, additionally sending them to UMA if enough time has elapsed
// since the last report.
void UpdateStats(base::TimeTicks now_ticks, base::Time now_wall_time);