Do not use FindOatFileFromOatLocation in DexFile_isDexOptNeeded

isDexOptNeeded is trying to sniff out bad files and
FindOatFileFromOatLocation will register the file on the opened oat
file list so later if the same process tries to run code from one of
the oats, it will find it already opened and not validate its contents
are up-to-date. This happens in the special case of the system server
which is responsible for scanning to make sure things are up-to-date
proactively, but also starts up services using those files.

Change-Id: Ia9b483a46336b46bc1ec22180e60099e74886927
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index 2539c92..a4b270d 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -197,8 +197,8 @@
   // A user build looks like this, and it will have no classes.dex in
   // the input for checksum validation.
   std::string oat_filename(OatFile::DexFilenameToOatFilename(filename.c_str()));
-  const OatFile* oat_file = class_linker->FindOatFileFromOatLocation(oat_filename);
-  if (oat_file != NULL && oat_file->GetOatDexFile(filename.c_str()) != NULL) {
+  UniquePtr<const OatFile> oat_file(OatFile::Open(oat_filename, oat_filename, NULL));
+  if (oat_file.get() != NULL && oat_file->GetOatDexFile(filename.c_str()) != NULL) {
     if (debug_logging) {
       LOG(INFO) << "DexFile_isDexOptNeeded ignoring precompiled file: " << filename.c_str();
     }
@@ -207,8 +207,8 @@
 
   // Check if we have an oat file in the cache
   std::string cache_location(GetArtCacheFilenameOrDie(oat_filename));
-  oat_file = class_linker->FindOatFileFromOatLocation(cache_location);
-  if (oat_file == NULL) {
+  oat_file.reset(OatFile::Open(cache_location, oat_filename, NULL));
+  if (oat_file.get() == NULL) {
     LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location
               << " does not exist for " << filename.c_str();
     return JNI_TRUE;