Enable dex madvise hints for low ram devices

Enable layout based madvise hints for low ram devices.

Reduces flash reads by 40% for AUPT use cases on low ram devices.

Test: build and flash
Bug: 63178181

(cherry picked from commit 63199d75a146cbcac1cbcac944cf054524ca8848)

Change-Id: Ica0abc10b8356fbd7ab38a71df91c2da74bf505b
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 2d8d6ba..d9cfa53 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -75,7 +75,7 @@
 static constexpr bool kPrintDlOpenErrorMessage = false;
 
 // If true, we advise the kernel about dex file mem map accesses.
-static constexpr bool kMadviseDexFileAccesses = false;
+static constexpr bool kMadviseDexFileAccesses = true;
 
 // Note for OatFileBase and descendents:
 //
@@ -1498,11 +1498,13 @@
 
 // Madvise the dex file based on the state we are moving to.
 void OatDexFile::MadviseDexFile(const DexFile& dex_file, MadviseState state) {
-  if (!kMadviseDexFileAccesses) {
+  const bool low_ram = Runtime::Current()->GetHeap()->IsLowMemoryMode();
+  // TODO: Also do madvise hints for non low ram devices.
+  if (!kMadviseDexFileAccesses || !low_ram) {
     return;
   }
   if (state == MadviseState::kMadviseStateAtLoad) {
-    if (Runtime::Current()->GetHeap()->IsLowMemoryMode()) {
+    if (low_ram) {
       // Default every dex file to MADV_RANDOM when its loaded by default for low ram devices.
       // Other devices have enough page cache to get performance benefits from loading more pages
       // into the page cache.