From 81dc83dd0c7d7e1217cc0abb34f7d6b87f6083c2 Mon Sep 17 00:00:00 2001 From: roynatech2544 Date: Wed, 29 Nov 2023 20:04:41 +0900 Subject: [PATCH] universal7885: libinit: Set low_ram prop if less than 4GB RAM --- .../libinit/init_universal7885.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/universal7885-common/libinit/init_universal7885.cpp b/universal7885-common/libinit/init_universal7885.cpp index ee67c4c..2c54346 100644 --- a/universal7885-common/libinit/init_universal7885.cpp +++ b/universal7885-common/libinit/init_universal7885.cpp @@ -27,6 +27,8 @@ #include +#include + #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #include @@ -71,6 +73,15 @@ static inline bool hasEnding(const std::string& str, char suffix) return !str.empty() && str.back() == suffix; } +static void setLowRamProp(void) { + static constexpr auto GB_3 = 3ull * 1024 * 1024 * 1024; + struct sysinfo sys {}; + + sysinfo(&sys); + if (sys.totalram <= GB_3) + property_override("ro.config.low_ram", "true"); +} + void vendor_load_properties() { std::string model; bool isNFC = false; @@ -95,6 +106,9 @@ void vendor_load_properties() { property_override("ro.boot.product.hardware.sku", "NFC"); } + // Set Low ram prop based on HW ram size + setLowRamProp(); + // Set model based on bootloader supplied model set_ro_build_prop("model", model); set_ro_build_prop("product", model, false);