Do not try to compile resource-only dex files.

This changes behavior in the case where we are asked to load a dex
file that does not exist or has no classes.dex entry.

Previously we would run dex2oat, which would log an error message and
fail. Now we skip running dex2oat, we report the DexOptStatus as
kNoDexOptNeeded, and we do not try to fall back to the missing
original dex files.

Bug: 21722039
(cherry picked from commit cb44b11a926696e34b3dc44288e762b4303cc128)

Change-Id: I84a85dc9ece54bcc0a5283f871e09bf68471c6e7
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index 4c0b0e2..7216fc7 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -174,6 +174,12 @@
   static std::vector<std::unique_ptr<const DexFile>> LoadDexFiles(
       const OatFile& oat_file, const char* dex_location);
 
+  // Returns true if there are dex files in the original dex location that can
+  // be compiled with dex2oat for this dex location.
+  // Returns false if there is no original dex file, or if the original dex
+  // file is an apk/zip without a classes.dex entry.
+  bool HasOriginalDexFiles();
+
   // If the dex file has been installed with a compiled oat file alongside
   // it, the compiled oat file will have the extension .odex, and is referred
   // to as the odex file. It is called odex for legacy reasons; the file is
@@ -312,6 +318,8 @@
   // Returns dex_checksum if a required checksum was located. Returns
   // null if the required checksum was not found.
   // The caller shouldn't clean up or free the returned pointer.
+  // This sets the has_original_dex_files_ field to true if a checksum was
+  // found for the dex_location_ dex file.
   const uint32_t* GetRequiredDexChecksum();
 
   // Returns the loaded odex file.
@@ -374,9 +382,10 @@
 
   // Cached value of the required dex checksum.
   // This should be accessed only by the GetRequiredDexChecksum() method.
-  uint32_t cached_required_dex_checksum;
-  bool required_dex_checksum_attempted = false;
-  bool required_dex_checksum_found;
+  uint32_t cached_required_dex_checksum_;
+  bool required_dex_checksum_attempted_ = false;
+  bool required_dex_checksum_found_;
+  bool has_original_dex_files_;
 
   // Cached value of the odex file name.
   // This should be accessed only by the OdexFileName() method.