Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 067ec8ba authored by Ben Chan's avatar Ben Chan Committed by ChromeOS Commit Bot
Browse files

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: default avatarBertrand Simonnet <bsimonnet@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: default avatarBen Chan <benchan@chromium.org>
parent 7e238f3b
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -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_) {
    if (IsOnOfficialBuild()) {
      LOG(INFO) << "uploader enabled";
    upload_service_.reset(new UploadService(new SystemProfileCache(), server_));
      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;
+3 −0
Original line number Diff line number Diff line
@@ -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);