Merge "Always pass --dex-location to profman"
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index a9383eb..a19ce09 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -740,6 +740,7 @@
static void run_profman(const std::vector<unique_fd>& profile_fds,
const unique_fd& reference_profile_fd,
const std::vector<unique_fd>* apk_fds,
+ const std::vector<std::string>* dex_locations,
bool copy_and_update) {
const char* profman_bin = is_debug_runtime() ? "/system/bin/profmand" : "/system/bin/profman";
@@ -762,6 +763,13 @@
}
}
+ std::vector<std::string> dex_location_args;
+ if (dex_locations != nullptr) {
+ for (size_t k = 0; k < dex_locations->size(); k++) {
+ dex_location_args.push_back("--dex-location=" + (*dex_locations)[k]);
+ }
+ }
+
// program name, reference profile fd, the final NULL and the profile fds
const char* argv[3 + profile_args.size() + apk_args.size() + (copy_and_update ? 1 : 0)];
int i = 0;
@@ -773,9 +781,13 @@
for (size_t k = 0; k < apk_args.size(); k++) {
argv[i++] = apk_args[k].c_str();
}
+ for (size_t k = 0; k < dex_location_args.size(); k++) {
+ argv[i++] = dex_location_args[k].c_str();
+ }
if (copy_and_update) {
argv[i++] = "--copy-and-update-profile-key";
}
+
// Do not add after dex2oat_flags, they should override others for debugging.
argv[i] = NULL;
@@ -787,20 +799,26 @@
[[ noreturn ]]
static void run_profman_merge(const std::vector<unique_fd>& profiles_fd,
const unique_fd& reference_profile_fd,
- const std::vector<unique_fd>* apk_fds = nullptr) {
- run_profman(profiles_fd, reference_profile_fd, apk_fds, /*copy_and_update*/false);
+ const std::vector<unique_fd>* apk_fds = nullptr,
+ const std::vector<std::string>* dex_locations = nullptr) {
+ run_profman(profiles_fd, reference_profile_fd, apk_fds, dex_locations,
+ /*copy_and_update*/false);
}
[[ noreturn ]]
static void run_profman_copy_and_update(unique_fd&& profile_fd,
unique_fd&& reference_profile_fd,
- unique_fd&& apk_fd) {
+ unique_fd&& apk_fd,
+ const std::string& dex_location) {
std::vector<unique_fd> profiles_fd;
profiles_fd.push_back(std::move(profile_fd));
std::vector<unique_fd> apk_fds;
apk_fds.push_back(std::move(apk_fd));
+ std::vector<std::string> dex_locations;
+ dex_locations.push_back(dex_location);
- run_profman(profiles_fd, reference_profile_fd, &apk_fds, /*copy_and_update*/true);
+ run_profman(profiles_fd, reference_profile_fd, &apk_fds, &dex_locations,
+ /*copy_and_update*/true);
}
// Decides if profile guided compilation is needed or not based on existing profiles.
@@ -2598,7 +2616,8 @@
}
}
-bool open_classpath_files(const std::string& classpath, std::vector<unique_fd>* apk_fds) {
+bool open_classpath_files(const std::string& classpath, std::vector<unique_fd>* apk_fds,
+ std::vector<std::string>* dex_locations) {
std::vector<std::string> classpaths_elems = base::Split(classpath, ":");
for (const std::string& elem : classpaths_elems) {
unique_fd fd(TEMP_FAILURE_RETRY(open(elem.c_str(), O_RDONLY)));
@@ -2607,6 +2626,7 @@
return false;
} else {
apk_fds->push_back(std::move(fd));
+ dex_locations->push_back(elem);
}
}
return true;
@@ -2636,7 +2656,8 @@
// Open the class paths elements. These will be used to filter out profile data that does
// not belong to the classpath during merge.
std::vector<unique_fd> apk_fds;
- if (!open_classpath_files(classpath, &apk_fds)) {
+ std::vector<std::string> dex_locations;
+ if (!open_classpath_files(classpath, &apk_fds, &dex_locations)) {
return false;
}
@@ -2644,7 +2665,7 @@
if (pid == 0) {
/* child -- drop privileges before continuing */
drop_capabilities(app_shared_gid);
- run_profman_merge(profiles_fd, snapshot_fd, &apk_fds);
+ run_profman_merge(profiles_fd, snapshot_fd, &apk_fds, &dex_locations);
}
/* parent */
@@ -2694,7 +2715,8 @@
// Open the classpath elements. These will be used to filter out profile data that does
// not belong to the classpath during merge.
std::vector<unique_fd> apk_fds;
- if (!open_classpath_files(classpath, &apk_fds)) {
+ std::vector<std::string> dex_locations;
+ if (!open_classpath_files(classpath, &apk_fds, &dex_locations)) {
return false;
}
@@ -2721,7 +2743,9 @@
/* child -- drop privileges before continuing */
drop_capabilities(AID_SYSTEM);
- run_profman_merge(profiles_fd, snapshot_fd, &apk_fds);
+ // The introduction of new access flags into boot jars causes them to
+ // fail dex file verification.
+ run_profman_merge(profiles_fd, snapshot_fd, &apk_fds, &dex_locations);
}
/* parent */
@@ -2784,7 +2808,8 @@
// The copy and update takes ownership over the fds.
run_profman_copy_and_update(std::move(dex_metadata_fd),
std::move(ref_profile_fd),
- std::move(apk_fd));
+ std::move(apk_fd),
+ code_path);
}
/* parent */