diff options
| author | 2015-04-30 07:34:27 +0000 | |
|---|---|---|
| committer | 2015-04-30 07:34:27 +0000 | |
| commit | af6535b39fb8630e02cd38ca594dec1d65be90cd (patch) | |
| tree | 85363c8b4d677ab20b7dcb61345483c2feac47d1 /runtime/dex_file.cc | |
| parent | de8e618e3c4b9ad5437772136ba30e49c3c95781 (diff) | |
| parent | f94b250f426c7f43f9ee78e39e07d6ee13842b20 (diff) | |
am f94b250f: am 0a50264b: Merge "ART: Allow oat files with duplicates classes in corner case"
* commit 'f94b250f426c7f43f9ee78e39e07d6ee13842b20':
ART: Allow oat files with duplicates classes in corner case
Diffstat (limited to 'runtime/dex_file.cc')
| -rw-r--r-- | runtime/dex_file.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index 20098e7482..dfe5a04d8f 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -153,6 +153,31 @@ bool DexFile::Open(const char* filename, const char* location, std::string* erro return false; } +static bool ContainsClassesDex(int fd, const char* filename) { + std::string error_msg; + std::unique_ptr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(fd, filename, &error_msg)); + if (zip_archive.get() == nullptr) { + return false; + } + std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(DexFile::kClassesDex, &error_msg)); + return (zip_entry.get() != nullptr); +} + +bool DexFile::MaybeDex(const char* filename) { + uint32_t magic; + std::string error_msg; + ScopedFd fd(OpenAndReadMagic(filename, &magic, &error_msg)); + if (fd.get() == -1) { + return false; + } + if (IsZipMagic(magic)) { + return ContainsClassesDex(fd.release(), filename); + } else if (IsDexMagic(magic)) { + return true; + } + return false; +} + int DexFile::GetPermissions() const { if (mem_map_.get() == nullptr) { return 0; |