Restore code inadvertently removed.
Code was removed by accident in:
https://android-review.googlesource.com/c/platform/art/+/1652387
Test: app startup
Bug: 183954825
Change-Id: I06d697a0b29a90d2d13dd0a19fb7f381933a6e29
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index 4e54c0d..62508f6 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -150,6 +150,20 @@
return nullptr;
}
+ if (!writable) {
+ Runtime* runtime = Runtime::Current();
+ // The runtime might not be available at this point if we're running
+ // dex2oat or oatdump.
+ if (runtime != nullptr) {
+ size_t madvise_size_limit = runtime->GetMadviseWillNeedSizeVdex();
+ Runtime::MadviseFileForRange(madvise_size_limit,
+ vdex->Size(),
+ vdex->Begin(),
+ vdex->End(),
+ vdex_filename);
+ }
+ }
+
return vdex;
}