From f344c7e01078291770e65e027239a2f81bb70ec5 Mon Sep 17 00:00:00 2001 From: dev-harsh1998 Date: Sun, 23 Jul 2017 20:23:23 +0200 Subject: [PATCH] land: Set dalvik heap & hwui through init * Also update copyright. Signed-off-by: Darshan Manjrekar --- init/init_land.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++-- product/display.mk | 23 ------------------ 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/init/init_land.cpp b/init/init_land.cpp index b9c4a86..c2fc1ae 100644 --- a/init/init_land.cpp +++ b/init/init_land.cpp @@ -1,5 +1,6 @@ /* Copyright (c) 2016, The CyanogenMod Project + Copyright (c) 2017, The LineageOS Project Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -31,13 +32,21 @@ #include #include #include -#include +#include +#include #include "vendor_init.h" #include "property_service.h" #include "log.h" #include "util.h" +char const *heapstartsize; +char const *heapgrowthlimit; +char const *heapsize; +char const *heapminfree; +char const *heapmaxfree; +char const *large_cache_height; + static void init_alarm_boot_properties() { int boot_reason; @@ -69,6 +78,31 @@ static void init_alarm_boot_properties() } } +void check_device() +{ + struct sysinfo sys; + + sysinfo(&sys); + + if (sys.totalram > 2048ull * 1024 * 1024) { + // from - phone-xxhdpi-3072-dalvik-heap.mk + heapstartsize = "8m"; + heapgrowthlimit = "288m"; + heapsize = "768m"; + heapminfree = "512k"; + heapmaxfree = "8m"; + large_cache_height = "1024"; + } else { + // from - phone-xxhdpi-2048-dalvik-heap.mk + heapstartsize = "16m"; + heapgrowthlimit = "192m"; + heapsize = "512m"; + heapminfree = "2m"; + heapmaxfree = "8m"; + large_cache_height = "1024"; + } +} + void vendor_load_properties() { std::ifstream fin; @@ -85,6 +119,26 @@ void vendor_load_properties() fin.close(); init_alarm_boot_properties(); + check_device(); + + property_set("dalvik.vm.heapstartsize", heapstartsize); + property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit); + property_set("dalvik.vm.heapsize", heapsize); + property_set("dalvik.vm.heaptargetutilization", "0.75"); + property_set("dalvik.vm.heapminfree", heapminfree); + property_set("dalvik.vm.heapmaxfree", heapmaxfree); + + property_set("ro.hwui.texture_cache_size", "72"); + property_set("ro.hwui.layer_cache_size", "48"); + property_set("ro.hwui.r_buffer_cache_size", "8"); + property_set("ro.hwui.path_cache_size", "32"); + property_set("ro.hwui.gradient_cache_size", "1"); + property_set("ro.hwui.drop_shadow_cache_size", "6"); + property_set("ro.hwui.texture_cache_flushrate", "0.4"); + property_set("ro.hwui.text_small_cache_width", "1024"); + property_set("ro.hwui.text_small_cache_height", "1024"); + property_set("ro.hwui.text_large_cache_width", "2048"); + property_set("ro.hwui.text_large_cache_height", large_cache_height); if (buf.find("S88537AA1") != std::string::npos) { property_set("ro.build.display.wtid", "SW_S88537AA1_V080_M20_MP_XM"); @@ -116,4 +170,4 @@ void vendor_load_properties() property_set("persist.sys.fp.vendor", "searchf"); property_set("ro.boot.fpsensor", "fpc"); } -} \ No newline at end of file +} diff --git a/product/display.mk b/product/display.mk index 0ad0211..b086c48 100644 --- a/product/display.mk +++ b/product/display.mk @@ -19,29 +19,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ libjni_livedisplay -# Dalvik -PRODUCT_PROPERTY_OVERRIDES += \ - dalvik.vm.heapgrowthlimit=192m \ - dalvik.vm.heapmaxfree=8m \ - dalvik.vm.heapminfree=4m \ - dalvik.vm.heapsize=384m \ - dalvik.vm.heapstartsize=16m \ - dalvik.vm.heaptargetutilization=0.75 - -# HWUI -PRODUCT_PROPERTY_OVERRIDES += \ - ro.hwui.drop_shadow_cache_size=6 \ - ro.hwui.gradient_cache_size=1 \ - ro.hwui.layer_cache_size=48 \ - ro.hwui.path_cache_size=32 \ - ro.hwui.r_buffer_cache_size=8 \ - ro.hwui.text_large_cache_width=2048 \ - ro.hwui.text_large_cache_height=2048 \ - ro.hwui.text_small_cache_width=1024 \ - ro.hwui.text_small_cache_height=1024 \ - ro.hwui.texture_cache_flushrate=0.4 \ - ro.hwui.texture_cache_size=72 - # Permissions PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.opengles.aep.xml:system/etc/permissions/android.hardware.opengles.aep.xml