Support loading vdex files without odex.

GetDexoptNeeded with 'verify' as filter will return false when a vdex is
available.

Test: 628-vdex, 820-vdex-multidex, test.py
Bug: 176960283
Change-Id: I3ac2f747d1e7f5331a49a22c94983959e3b60122
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index d4f4d95..a22e043 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -163,6 +163,16 @@
                                std::unique_ptr<VdexFile>&& vdex_file,
                                const std::string& location);
 
+  // Initialize OatFile instance from an already loaded VdexFile. The dex files
+  // will be opened through `zip_fd` or `dex_location` if `zip_fd` is -1.
+  static OatFile* OpenFromVdex(int zip_fd,
+                               std::unique_ptr<VdexFile>&& vdex_file,
+                               const std::string& location,
+                               std::string* error_msg);
+
+  // Return whether the `OatFile` uses a vdex-only file.
+  bool IsBackedByVdexOnly() const;
+
   virtual ~OatFile();
 
   bool IsExecutable() const {
@@ -467,6 +477,7 @@
   friend class OatClass;
   friend class art::OatDexFile;
   friend class OatDumper;  // For GetBase and GetLimit
+  friend class OatFileBackedByVdex;
   friend class OatFileBase;
   DISALLOW_COPY_AND_ASSIGN(OatFile);
 };
@@ -582,7 +593,8 @@
   // Create an OatDexFile wrapping an existing DexFile. Will set the OatDexFile
   // pointer in the DexFile.
   OatDexFile(const OatFile* oat_file,
-             const DexFile* dex_file,
+             const uint8_t* dex_file_pointer,
+             uint32_t dex_file_checksum,
              const std::string& dex_file_location,
              const std::string& canonical_dex_file_location);
 
@@ -607,6 +619,7 @@
 
   friend class OatFile;
   friend class OatFileBase;
+  friend class OatFileBackedByVdex;
   DISALLOW_COPY_AND_ASSIGN(OatDexFile);
 };