dex2oat: handle the case when a dm file and a vdex file are passed.
Package manager can pass both when an app moves location (for example,
it moves to a sdcard).
In this situation, just arbitrarily take the vdex file.
Test: test.py
Bug: 210081649
Bug: 210431530
Change-Id: I5ff972ae6ad86efa60f9ae25dae0ab9202ab9ff0
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 3d956e2..32016d1 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -705,11 +705,6 @@
Usage("--oat-fd should not be used with --image");
}
- if ((input_vdex_fd_ != -1 || !input_vdex_.empty()) &&
- (dm_fd_ != -1 || !dm_file_location_.empty())) {
- Usage("An input vdex should not be passed with a .dm file");
- }
-
if (!parser_options->oat_symbols.empty() &&
parser_options->oat_symbols.size() != oat_filenames_.size()) {
Usage("--oat-file arguments do not match --oat-symbols arguments");
@@ -1348,11 +1343,16 @@
}
}
+ // If we have a dm file and a vdex file, we (arbitrarily) pick the vdex file.
+ // In theory the files should be the same.
if (dm_file_ != nullptr) {
- DCHECK(input_vdex_file_ == nullptr);
- input_vdex_file_ = VdexFile::OpenFromDm(dm_file_location_, *dm_file_);
- if (input_vdex_file_ != nullptr) {
- VLOG(verifier) << "Doing fast verification with vdex from DexMetadata archive";
+ if (input_vdex_file_ == nullptr) {
+ input_vdex_file_ = VdexFile::OpenFromDm(dm_file_location_, *dm_file_);
+ if (input_vdex_file_ != nullptr) {
+ VLOG(verifier) << "Doing fast verification with vdex from DexMetadata archive";
+ }
+ } else {
+ LOG(INFO) << "Ignoring vdex file in dex metadata due to vdex file already being passed";
}
}