Restore fallback behavior in the no-image stripped-dex case.
Add --strip-dex option to run-test to test this case.
Bug: 27599626
Change-Id: I010543f48c39adbda007e2e05dda62ac1d70715c
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 78e372a..3f95772 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -492,10 +492,21 @@
const ImageInfo* image_info = GetImageInfo();
if (image_info == nullptr) {
VLOG(oat) << "No image for oat image checksum to match against.";
- return true;
- }
- if (file.GetOatHeader().GetImageFileLocationOatChecksum() != GetCombinedImageChecksum()) {
+ if (HasOriginalDexFiles()) {
+ return true;
+ }
+
+ // If there is no original dex file to fall back to, grudgingly accept
+ // the oat file. This could technically lead to crashes, but there's no
+ // way we could find a better oat file to use for this dex location,
+ // and it's better than being stuck in a boot loop with no way out.
+ // The problem will hopefully resolve itself the next time the runtime
+ // starts up.
+ LOG(WARNING) << "Dex location " << dex_location_ << " does not seem to include dex file. "
+ << "Allow oat file use. This is potentially dangerous.";
+ } else if (file.GetOatHeader().GetImageFileLocationOatChecksum()
+ != GetCombinedImageChecksum()) {
VLOG(oat) << "Oat image checksum does not match image checksum.";
return true;
}
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 94f6345..3846605 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -364,7 +364,7 @@
// However, if the app was part of /system and preopted, there is no original dex file
// available. In that case grudgingly accept the oat file.
- if (!DexFile::MaybeDex(dex_location)) {
+ if (!oat_file_assistant.HasOriginalDexFiles()) {
accept_oat_file = true;
LOG(WARNING) << "Dex location " << dex_location << " does not seem to include dex file. "
<< "Allow oat file use. This is potentially dangerous.";