Revert "Revert "Don't embed the dex code in the oat file if dex is uncompressed.""
Bug: 63920015
Bug: 70854754
Test: oat_writer_test.cc, test.py
Revert was due to userdebug/user differences, which is fixed with:
https://googleplex-android-review.googlesource.com/#/c/platform/build/+/3434091/
This CL also fixes oatdump when the dex code is not in the .vdex file.
This reverts commit e166e67666bf4b23e4ed0a98f5e2bb3cae9cee7d.
Change-Id: Iec924be2ff8f03cf2ebe306e7a0018241f33beb0
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index 637578e..62519fc 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -253,7 +253,7 @@
}
std::vector<OutputStream*> rodata;
- std::vector<std::unique_ptr<MemMap>> opened_dex_files_map;
+ std::vector<std::unique_ptr<MemMap>> opened_dex_files_maps;
std::vector<std::unique_ptr<const DexFile>> opened_dex_files;
// Now that we have finalized key_value_store_, start writing the oat file.
for (size_t i = 0, size = oat_writers.size(); i != size; ++i) {
@@ -266,7 +266,7 @@
dex_file->GetLocation().c_str(),
dex_file->GetLocationChecksum());
- std::unique_ptr<MemMap> cur_opened_dex_files_map;
+ std::vector<std::unique_ptr<MemMap>> cur_opened_dex_files_maps;
std::vector<std::unique_ptr<const DexFile>> cur_opened_dex_files;
bool dex_files_ok = oat_writers[i]->WriteAndOpenDexFiles(
vdex_files[i].GetFile(),
@@ -276,12 +276,14 @@
&key_value_store,
/* verify */ false, // Dex files may be dex-to-dex-ed, don't verify.
/* update_input_vdex */ false,
- &cur_opened_dex_files_map,
+ &cur_opened_dex_files_maps,
&cur_opened_dex_files);
ASSERT_TRUE(dex_files_ok);
- if (cur_opened_dex_files_map != nullptr) {
- opened_dex_files_map.push_back(std::move(cur_opened_dex_files_map));
+ if (!cur_opened_dex_files_maps.empty()) {
+ for (std::unique_ptr<MemMap>& cur_map : cur_opened_dex_files_maps) {
+ opened_dex_files_maps.push_back(std::move(cur_map));
+ }
for (std::unique_ptr<const DexFile>& cur_dex_file : cur_opened_dex_files) {
// dex_file_oat_index_map_.emplace(dex_file.get(), i);
opened_dex_files.push_back(std::move(cur_dex_file));