Run dex2oat if the APK is compressed.
This CL updates OatFileAssistant. After this change, if the APK is
compressed and the current oat file doesn't contain dex code,
OatFileAssistant::GetDexOptNeeded will return true.
Bug: 267143543
Test: atest art_standalone_runtime_tests:OatFileAssistantTest
Test: -
1. Install a compressed APK and a DM file that only contains a VDEX
file.
2. See dex2oat invoked.
Test: -
1. Install an uncompressed APK and a DM file that only contains a
VDEX file.
2. See dex2oat not invoked.
Ignore-AOSP-First: Contains internal-only changes. Will cherry-pick the
AOSP part as soon as the CL is merged.
Change-Id: If057858a614e493e00d58463af20e723f98e68b5
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index 7001650..81cd231 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -106,6 +106,9 @@
// Dexopt should be performed if the current oat file was compiled without a primary image,
// and the runtime is now running with a primary image loaded from disk.
bool primaryBootImageBecomesUsable : 1;
+ // Dexopt should be performed if the APK is compressed and the current oat/vdex file doesn't
+ // contain dex code.
+ bool needExtraction : 1;
};
// Represents the location of the current oat file and/or vdex file.
@@ -516,6 +519,9 @@
return GetOatFileAssistantContext()->GetRuntimeOptions();
}
+ // Returns whether the zip file only contains uncompressed dex.
+ bool ZipFileOnlyContainsUncompressedDex();
+
std::string dex_location_;
// The class loader context to check against, or null representing that the check should be
@@ -534,8 +540,9 @@
// Whether only oat files from trusted locations are loaded executable.
const bool only_load_trusted_executable_ = false;
- // Whether the potential zip file only contains uncompressed dex.
- // Will be set during GetRequiredDexChecksums.
+
+ // Cached value of whether the potential zip file only contains uncompressed dex.
+ // This should be accessed only by the ZipFileOnlyContainsUncompressedDex() method.
bool zip_file_only_contains_uncompressed_dex_ = true;
// Cached value of the required dex checksums.