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>
This commit is contained in:
parent
7e238f3bcb
commit
067ec8ba78
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue