summaryrefslogtreecommitdiff
path: root/runtime/native/dalvik_system_DexFile.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2022-02-01 12:52:36 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2022-02-02 17:18:15 +0000
commit818e87261bd5b144369deb5c44929fd6be8ded59 (patch)
treed076e3c655f8d35204a0d65d07f8dd610aa843b3 /runtime/native/dalvik_system_DexFile.cc
parentc0673f0c20de4a95b53e548e0d7d7cc9f9a4bd99 (diff)
Only return the vdex file as an optimization file when we don't use the oat file.
Test: adb shell dumpsys pinner doesn't return duplicate vdex entries. Bug: 217137351 Change-Id: If162da2acd3cbccc5fe4f06a5911c0fc0f49544b
Diffstat (limited to 'runtime/native/dalvik_system_DexFile.cc')
-rw-r--r--runtime/native/dalvik_system_DexFile.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index f8ad7f1b7a..d714206241 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -820,6 +820,7 @@ static jobjectArray DexFile_getDexFileOutputPaths(JNIEnv* env,
std::string vdex_filename;
// Check if the file is in the boot classpath by looking at image spaces which
// have oat files.
+ bool is_vdex_only = false;
for (gc::space::ImageSpace* space : Runtime::Current()->GetHeap()->GetBootImageSpaces()) {
const OatFile* oat_file = space->GetOatFile();
if (oat_file != nullptr) {
@@ -829,6 +830,7 @@ static jobjectArray DexFile_getDexFileOutputPaths(JNIEnv* env,
filename.c_str()) {
oat_filename = GetSystemImageFilename(oat_file->GetLocation().c_str(),
target_instruction_set);
+ is_vdex_only = oat_file->IsBackedByVdexOnly();
break;
}
}
@@ -851,26 +853,33 @@ static jobjectArray DexFile_getDexFileOutputPaths(JNIEnv* env,
}
oat_filename = best_oat_file->GetLocation();
- }
- vdex_filename = GetVdexFilename(oat_filename);
-
- ScopedLocalRef<jstring> jvdexFilename(env, env->NewStringUTF(vdex_filename.c_str()));
- if (jvdexFilename.get() == nullptr) {
- return nullptr;
+ is_vdex_only = best_oat_file->IsBackedByVdexOnly();
}
ScopedLocalRef<jstring> joatFilename(env, env->NewStringUTF(oat_filename.c_str()));
if (joatFilename.get() == nullptr) {
return nullptr;
}
- // Now create output array and copy the set into it.
- jobjectArray result = env->NewObjectArray(2,
- WellKnownClasses::java_lang_String,
- nullptr);
- env->SetObjectArrayElement(result, 0, jvdexFilename.get());
- env->SetObjectArrayElement(result, 1, joatFilename.get());
+ if (is_vdex_only) {
+ jobjectArray result = env->NewObjectArray(1,
+ WellKnownClasses::java_lang_String,
+ nullptr);
+ env->SetObjectArrayElement(result, 0, joatFilename.get());
+ return result;
+ } else {
+ vdex_filename = GetVdexFilename(oat_filename);
+ ScopedLocalRef<jstring> jvdexFilename(env, env->NewStringUTF(vdex_filename.c_str()));
+ if (jvdexFilename.get() == nullptr) {
+ return nullptr;
+ }
- return result;
+ jobjectArray result = env->NewObjectArray(2,
+ WellKnownClasses::java_lang_String,
+ nullptr);
+ env->SetObjectArrayElement(result, 0, jvdexFilename.get());
+ env->SetObjectArrayElement(result, 1, joatFilename.get());
+ return result;
+ }
}
static jlong DexFile_getStaticSizeOfDexFile(JNIEnv* env, jclass, jobject cookie) {