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

Commit d227679b authored by Bertrand Simonnet's avatar Bertrand Simonnet Committed by Android Git Automerger
Browse files

am 6b8fd10a: am 300b1a6b: Merge "metricsd: Don\'t crash when some metadata is missing."

* commit '6b8fd10a':
  metricsd: Don't crash when some metadata is missing.
parents 60413943 6b8fd10a
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -48,6 +48,6 @@ void MetricsLog::IncrementUncleanShutdownCount() {
  stability->set_unclean_system_shutdown_count(current + 1);
  stability->set_unclean_system_shutdown_count(current + 1);
}
}


void MetricsLog::PopulateSystemProfile(SystemProfileSetter* profile_setter) {
bool MetricsLog::PopulateSystemProfile(SystemProfileSetter* profile_setter) {
  profile_setter->Populate(uma_proto());
  return profile_setter->Populate(uma_proto());
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ class MetricsLog : public metrics::MetricsLogBase {
  void IncrementUncleanShutdownCount();
  void IncrementUncleanShutdownCount();


  // Populate the system profile with system information using setter.
  // Populate the system profile with system information using setter.
  void PopulateSystemProfile(SystemProfileSetter* setter);
  bool PopulateSystemProfile(SystemProfileSetter* setter);


 private:
 private:
  FRIEND_TEST(UploadServiceTest, LogContainsAggregatedValues);
  FRIEND_TEST(UploadServiceTest, LogContainsAggregatedValues);
+7 −4
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ bool SystemProfileCache::Initialize() {


  if (!base::SysInfo::GetLsbReleaseValue("BRILLO_BUILD_TARGET_ID",
  if (!base::SysInfo::GetLsbReleaseValue("BRILLO_BUILD_TARGET_ID",
                                         &profile_.build_target_id)) {
                                         &profile_.build_target_id)) {
    LOG(ERROR) << "Could not initialize system profile.";
    LOG(ERROR) << "BRILLO_BUILD_TARGET_ID is not set in /etc/lsb-release.";
    return false;
    return false;
  }
  }


@@ -109,11 +109,12 @@ bool SystemProfileCache::InitializeOrCheck() {
  return initialized_ || Initialize();
  return initialized_ || Initialize();
}
}


void SystemProfileCache::Populate(
bool SystemProfileCache::Populate(
    metrics::ChromeUserMetricsExtension* metrics_proto) {
    metrics::ChromeUserMetricsExtension* metrics_proto) {
  CHECK(metrics_proto);
  CHECK(metrics_proto);
  CHECK(InitializeOrCheck())
  if (not InitializeOrCheck()) {
      << "failed to initialize system information.";
    return false;
  }


  // The client id is hashed before being sent.
  // The client id is hashed before being sent.
  metrics_proto->set_client_id(
  metrics_proto->set_client_id(
@@ -132,6 +133,8 @@ void SystemProfileCache::Populate(
  metrics::SystemProfileProto_BrilloDeviceData* device_data =
  metrics::SystemProfileProto_BrilloDeviceData* device_data =
      profile_proto->mutable_brillo();
      profile_proto->mutable_brillo();
  device_data->set_build_target_id(profile_.build_target_id);
  device_data->set_build_target_id(profile_.build_target_id);

  return true;
}
}


std::string SystemProfileCache::GetPersistentGUID(
std::string SystemProfileCache::GetPersistentGUID(
+1 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@ class SystemProfileCache : public SystemProfileSetter {
  SystemProfileCache(bool testing, const std::string& config_root);
  SystemProfileCache(bool testing, const std::string& config_root);


  // Populates the ProfileSystem protobuf with system information.
  // Populates the ProfileSystem protobuf with system information.
  void Populate(metrics::ChromeUserMetricsExtension* metrics_proto) override;
  bool Populate(metrics::ChromeUserMetricsExtension* metrics_proto) override;


  // Converts a string representation of the channel to a
  // Converts a string representation of the channel to a
  // SystemProfileProto_Channel
  // SystemProfileProto_Channel
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ class SystemProfileSetter {
 public:
 public:
  virtual ~SystemProfileSetter() {}
  virtual ~SystemProfileSetter() {}
  // Populates the protobuf with system informations.
  // Populates the protobuf with system informations.
  virtual void Populate(metrics::ChromeUserMetricsExtension* profile_proto) = 0;
  virtual bool Populate(metrics::ChromeUserMetricsExtension* profile_proto) = 0;
};
};


#endif  // METRICS_UPLOADER_SYSTEM_PROFILE_SETTER_H_
#endif  // METRICS_UPLOADER_SYSTEM_PROFILE_SETTER_H_
Loading