Fix dex location filtering in dex2oat

Previously we were filtering dex location against profile keys,
this meant qualified ones like /system/.../app.apk would not match
the profile key app.apk in the profile. This CL fixes changes the
behavior to filter based on the profile key of the dex file location.

Fixed OatWriter checksum for raw data case (also found by regression
test).

Added missing FlushCloseOutputFiles to CompileImage causing DCHECK
failures for File destructor.

All the fixes are regression tested by dex2oat_test.

Test: test-art-host-gtest-dex2oat_test

Bug: 34929159
Bug: 35761072

Change-Id: I1bdc949bd644bfab1c8fea0b737a132b487a653b
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index cac5449..d232714 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -8933,7 +8933,7 @@
   return ret;
 }
 
-std::unordered_set<std::string> ClassLinker::GetClassDescriptorsForProfileKeys(
+std::unordered_set<std::string> ClassLinker::GetClassDescriptorsForResolvedClasses(
     const std::set<DexCacheResolvedClasses>& classes) {
   ScopedTrace trace(__PRETTY_FUNCTION__);
   std::unordered_set<std::string> ret;
@@ -8948,14 +8948,13 @@
       if (dex_cache != nullptr) {
         const DexFile* dex_file = dex_cache->GetDexFile();
         // There could be duplicates if two dex files with the same location are mapped.
-        location_to_dex_file.emplace(
-            ProfileCompilationInfo::GetProfileDexFileKey(dex_file->GetLocation()), dex_file);
+        location_to_dex_file.emplace(dex_file->GetLocation(), dex_file);
       }
     }
   }
   for (const DexCacheResolvedClasses& info : classes) {
-    const std::string& profile_key = info.GetDexLocation();
-    auto found = location_to_dex_file.find(profile_key);
+    const std::string& location = info.GetDexLocation();
+    auto found = location_to_dex_file.find(location);
     if (found != location_to_dex_file.end()) {
       const DexFile* dex_file = found->second;
       VLOG(profiler) << "Found opened dex file for " << dex_file->GetLocation() << " with "
@@ -8967,7 +8966,7 @@
         ret.insert(descriptor);
       }
     } else {
-      VLOG(class_linker) << "Failed to find opened dex file for profile key " << profile_key;
+      VLOG(class_linker) << "Failed to find opened dex file for location " << location;
     }
   }
   return ret;