diff options
-rw-r--r-- | odrefresh/odr_config.h | 6 | ||||
-rw-r--r-- | odrefresh/odrefresh.cc | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/odrefresh/odr_config.h b/odrefresh/odr_config.h index 20eca87898..eb819ee29d 100644 --- a/odrefresh/odr_config.h +++ b/odrefresh/odr_config.h @@ -104,6 +104,12 @@ class OdrSystemProperties : public tools::SystemProperties { auto begin() const { return system_properties_->begin(); } auto end() const { return system_properties_->end(); } + // Return a given property's value if it exists in the map. + std::optional<std::string> GetOrNull(const std::string& key) const { + auto it = system_properties_->find(key); + return it != system_properties_->end() ? std::make_optional(it->second) : std::nullopt; + } + protected: std::string GetProperty(const std::string& key) const override { auto it = system_properties_->find(key); diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc index 0110a6ec45..f0b8b44d23 100644 --- a/odrefresh/odrefresh.cc +++ b/odrefresh/odrefresh.cc @@ -1102,12 +1102,15 @@ WARN_UNUSED bool OnDeviceRefresh::CheckSystemPropertiesAreDefault() const { const OdrSystemProperties& system_properties = config_.GetSystemProperties(); for (const SystemPropertyConfig& system_property_config : *kSystemProperties.get()) { - std::string property = system_properties.GetOrEmpty(system_property_config.name); - DCHECK_NE(property, ""); + // Note that the `kSystemPropertySystemServerCompilerFilterOverride` property has an empty + // default value, so we use the `GetOrNull` method and check against nullopt + std::optional<std::string> property = system_properties.GetOrNull(system_property_config.name); + DCHECK(property.has_value()) << "Property " << system_property_config.name + << " does not exist in system properties map!"; - if (property != system_property_config.default_value) { + if (*property != system_property_config.default_value) { LOG(INFO) << "System property " << system_property_config.name << " has a non-default value (" - << property << ")."; + << *property << ")."; return false; } } |