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/runtime/zip_archive.cc b/runtime/zip_archive.cc
index f3d4d77..2caed4b 100644
--- a/runtime/zip_archive.cc
+++ b/runtime/zip_archive.cc
@@ -29,6 +29,7 @@
#include "base/bit_utils.h"
#include "base/unix_file/fd_file.h"
+#include "dex/dex_file.h"
namespace art {
@@ -49,11 +50,15 @@
return zip_entry_->method == kCompressStored;
}
-bool ZipEntry::IsAlignedTo(size_t alignment) {
+bool ZipEntry::IsAlignedTo(size_t alignment) const {
DCHECK(IsPowerOfTwo(alignment)) << alignment;
return IsAlignedParam(zip_entry_->offset, static_cast<int>(alignment));
}
+bool ZipEntry::IsAlignedToDexHeader() const {
+ return IsAlignedTo(alignof(DexFile::Header));
+}
+
ZipEntry::~ZipEntry() {
delete zip_entry_;
}