odrefresh: ensure dalvik-cache exists for cache-info.xml file
Ensure ART module apexdata/dalvik-cache directory exist before writing
cache-info.xml.
Minor comment clarifications.
Bug: 160683548
Test: manual, observe updated module only recompiles on initial reboot.
Change-Id: I51e5f0bc35bc6de5ae3bfb4ce7a6ab5e0dd4fe29
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index 8368a64..672363e 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -332,6 +332,12 @@
}
}
+ const std::string dir_name = android::base::Dirname(cache_info_filename_);
+ if (!EnsureDirectoryExists(dir_name)) {
+ LOG(ERROR) << "Could not create directory: " << QuotePath(dir_name);
+ return;
+ }
+
std::optional<art_apex::ArtModuleInfo> art_module_info = GenerateArtModuleInfo();
if (!art_module_info.has_value()) {
LOG(ERROR) << "Unable to generate cache provenance";
@@ -345,21 +351,21 @@
std::optional<std::vector<art_apex::Component>> bcp_components =
GenerateBootExtensionComponents();
if (!bcp_components.has_value()) {
+ LOG(ERROR) << "No boot classpath extension components.";
return;
}
std::optional<std::vector<art_apex::Component>> system_server_components =
GenerateSystemServerComponents();
if (!system_server_components.has_value()) {
+ LOG(ERROR) << "No system_server extension components.";
return;
}
std::ofstream out(cache_info_filename_.c_str());
- art_apex::CacheInfo info{
- art_module_infos,
- {{ art_apex::Dex2oatBootClasspath {bcp_components.value()}}},
- {{ art_apex::SystemServerClasspath {system_server_components.value()}}}
- };
+ art_apex::CacheInfo info{art_module_infos,
+ {{art_apex::Dex2oatBootClasspath{bcp_components.value()}}},
+ {{art_apex::SystemServerClasspath{system_server_components.value()}}}};
art_apex::write(out, info);
}
@@ -509,10 +515,13 @@
if (apex_info->getIsFactory()) {
// Remove any artifacts on /data as they are not necessary and no compilation is necessary.
+ LOG(INFO) << "Factory APEX mounted.";
return cleanup_return(ExitCode::kOkay);
}
if (!OS::FileExists(cache_info_filename_.c_str())) {
+ // If the cache info file does not exist, assume compilation is required because the
+ // file is missing and because the current ART APEX is not factory installed.
PLOG(ERROR) << "No prior cache-info file: " << QuotePath(cache_info_filename_);
return cleanup_return(ExitCode::kCompilationRequired);
}