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);