From a0399df8ed081a262de33a6c6c2563c97aea6678 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 15 Aug 2016 15:41:06 +0200 Subject: z2_plus: init: Dynamically set Dalvik properties Change-Id: I656cbed7abf351fea4129e7ff3c930eb9d8914ae Signed-off-by: dd3boh --- device.mk | 3 --- init/init_z2_plus.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/device.mk b/device.mk index 97bba06..6a24852 100644 --- a/device.mk +++ b/device.mk @@ -73,9 +73,6 @@ TARGET_SCREEN_WIDTH := 1080 # HWUI overrides $(call inherit-product, frameworks/native/build/phone-xxhdpi-3072-hwui-memory.mk) -# Dalvik overrides -$(call inherit-product, frameworks/native/build/phone-xxhdpi-3072-dalvik-heap.mk) - # Haters gonna hate.. PRODUCT_CHARACTERISTICS := nosdcard diff --git a/init/init_z2_plus.cpp b/init/init_z2_plus.cpp index fd30f51..33fe6b4 100644 --- a/init/init_z2_plus.cpp +++ b/init/init_z2_plus.cpp @@ -36,6 +36,9 @@ #include "log.h" #include "util.h" +char const *heapminfree; +char const *heapmaxfree; + static void init_alarm_boot_properties() { int boot_reason; @@ -67,6 +70,23 @@ static void init_alarm_boot_properties() } } +void check_ram() +{ + struct sysinfo sys; + + sysinfo(&sys); + + if (sys.totalram > 3072ull * 1024 * 1024) { + // from - phone-xxxhdpi-4096-dalvik-heap.mk + heapminfree = "4m"; + heapmaxfree = "16m"; + } else { + // from - phone-xxhdpi-3072-dalvik-heap.mk + heapminfree = "512k"; + heapmaxfree = "8m"; + } +} + void vendor_load_properties() { char device[PROP_VALUE_MAX]; char rf_version[PROP_VALUE_MAX]; @@ -77,6 +97,15 @@ void vendor_load_properties() { return; property_set("ro.product.model", "Z2 Plus"); + + check_ram(); + + property_set("dalvik.vm.heapstartsize", "8m"); + property_set("dalvik.vm.heapgrowthlimit", "256m"); + property_set("dalvik.vm.heapsize", "512m"); + property_set("dalvik.vm.heaptargetutilization", "0.75"); + property_set("dalvik.vm.heapminfree", heapminfree); + property_set("dalvik.vm.heapmaxfree", heapmaxfree); init_alarm_boot_properties(); } -- cgit v1.2.3