Fix dumpsys meminfo for art

Bug: 10112253

(cherry picked from commit fb2f70c7678d33c2027cdd0285d8b5421876e6aa)

Change-Id: I149c30242f3c9ef1f67b95e26731c2505e840171
diff --git a/runtime/utils.cc b/runtime/utils.cc
index ac5cae2..01441a2 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1196,7 +1196,7 @@
     LOG(FATAL) << "Expected path in location to be absolute: "<< location;
   }
   std::string cache_file(location, 1);  // skip leading slash
-  if (!EndsWith(location, ".dex") || !EndsWith(location, ".art")) {
+  if (!EndsWith(location, ".dex") && !EndsWith(location, ".art")) {
     cache_file += "/";
     cache_file += DexFile::kClassesDex;
   }
diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc
index 2633964..b43177b 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -335,4 +335,18 @@
   EXPECT_FALSE(EndsWith("oo", "foo"));
 }
 
+void CheckGetDalvikCacheFilenameOrDie(const char* in, const char* out) {
+  std::string expected(getenv("ANDROID_DATA"));
+  expected += "/dalvik-cache/";
+  expected += out;
+  EXPECT_STREQ(expected.c_str(), GetDalvikCacheFilenameOrDie(in).c_str());
+}
+
+TEST_F(UtilsTest, GetDalvikCacheFilenameOrDie) {
+  CheckGetDalvikCacheFilenameOrDie("/system/app/Foo.apk", "system@app@Foo.apk@classes.dex");
+  CheckGetDalvikCacheFilenameOrDie("/data/app/foo-1.apk", "data@app@foo-1.apk@classes.dex");
+  CheckGetDalvikCacheFilenameOrDie("/system/framework/core.jar", "system@framework@core.jar@classes.dex");
+  CheckGetDalvikCacheFilenameOrDie("/system/framework/boot.art", "system@framework@boot.art");
+}
+
 }  // namespace art