diff options
author | 2023-07-20 16:37:14 +0100 | |
---|---|---|
committer | 2023-07-21 07:34:20 +0000 | |
commit | d00ef2519e95094b670aebf00ec5245b50c5648b (patch) | |
tree | 45fc026f29405819696bc14af3d6a1981d73e9fa | |
parent | 0102195ca46933ec63b1618a70d7358fe09420cb (diff) |
Fix odrefresh's queries on system properties.
Starting from r.android.com/2664820, odrefresh queries system properties
from OdrConfig instead of querying them directly. This gives us the
ability to mock system properties in unit tests.
However, some system properties should be ignored during change
detection, and they were excluded from OdrConfig, so querying them from
OdrConfig would yield nothing.
This CL fixes the problem by postponing the exclusion to later stages.
Specifically, after this change, the ignored system properties are added
to OdrConfig so that they can be read by odrefresh, and they are then
excluded from cache info and skipped during change detection.
Bug: 292079794
Test: atest odsign_e2e_tests_full
Change-Id: Iea81b0c51f60a24105d2211948219f8dbb8202ec
-rw-r--r-- | odrefresh/odrefresh.cc | 8 | ||||
-rw-r--r-- | odrefresh/odrefresh_main.cc | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc index 3de6f5a4a1..d2ed00de5c 100644 --- a/odrefresh/odrefresh.cc +++ b/odrefresh/odrefresh.cc @@ -746,7 +746,9 @@ Result<void> OnDeviceRefresh::WriteCacheInfo() const { std::vector<art_apex::KeyValuePair> system_properties; for (const auto& [key, value] : config_.GetSystemProperties()) { - system_properties.emplace_back(key, value); + if (!art::ContainsElement(kIgnoredSystemProperties, key)) { + system_properties.emplace_back(key, value); + } } std::optional<std::vector<apex::ApexInfo>> apex_info_list = GetApexInfoList(); @@ -1062,7 +1064,9 @@ WARN_UNUSED bool OnDeviceRefresh::CheckSystemPropertiesHaveNotChanged( const OdrSystemProperties& system_properties = config_.GetSystemProperties(); for (const auto& [key, value] : system_properties) { - checked_properties.insert(key); + if (!art::ContainsElement(kIgnoredSystemProperties, key)) { + checked_properties.insert(key); + } } for (const std::string& name : checked_properties) { diff --git a/odrefresh/odrefresh_main.cc b/odrefresh/odrefresh_main.cc index a2a5ec23e4..f954dfce90 100644 --- a/odrefresh/odrefresh_main.cc +++ b/odrefresh/odrefresh_main.cc @@ -45,7 +45,6 @@ using ::android::base::StartsWith; using ::art::odrefresh::CompilationOptions; using ::art::odrefresh::ExitCode; using ::art::odrefresh::kCheckedSystemPropertyPrefixes; -using ::art::odrefresh::kIgnoredSystemProperties; using ::art::odrefresh::kSystemProperties; using ::art::odrefresh::kSystemPropertySystemServerCompilerFilterOverride; using ::art::odrefresh::OdrCompilationLog; @@ -205,7 +204,7 @@ void GetSystemProperties(std::unordered_map<std::string, std::string>* system_pr return; } for (const char* prefix : kCheckedSystemPropertyPrefixes) { - if (StartsWith(name, prefix) && !art::ContainsElement(kIgnoredSystemProperties, name)) { + if (StartsWith(name, prefix)) { (*system_properties)[name] = value; } } |