From 05e437c22a73f6bc6bbc886cc913bf67eaade316 Mon Sep 17 00:00:00 2001 From: Lucchetto Date: Mon, 8 Mar 2021 21:10:12 +0600 Subject: [PATCH] sdm660-common: init: Adapt libinit to Android 11 * Remove build.description from common tree as well --- init/Android.bp | 9 ++++--- init/init_sdm660.cpp | 63 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/init/Android.bp b/init/Android.bp index 0743cf97..dd596b9f 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -1,5 +1,5 @@ // -// Copyright (C) 2019 The LineageOS Project +// Copyright (C) 2019-2020 The LineageOS Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,10 +18,11 @@ cc_library_static { name: "libinit_sdm660", recovery_available: true, srcs: ["init_sdm660.cpp"], - whole_static_libs: ["libbase"], include_dirs: [ "system/core/base/include", - "system/core/init", + "system/core/init" ], - shared_libs: ["libbase"], + shared_libs: [ + "libbase", + ] } diff --git a/init/init_sdm660.cpp b/init/init_sdm660.cpp index 28b13dd4..19edc6c4 100644 --- a/init/init_sdm660.cpp +++ b/init/init_sdm660.cpp @@ -1,7 +1,6 @@ /* Copyright (c) 2016, The CyanogenMod Project - Copyright (c) 2019, The LineageOS Project - + Copyright (c) 2019-2020, The LineageOS Project Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -14,7 +13,6 @@ * Neither the name of The Linux Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT @@ -41,27 +39,60 @@ #include #include "vendor_init.h" +#include "property_service.h" using android::base::GetProperty; -using android::base::SetProperty; using android::base::ReadFileToString; -using android::base::Trim; char const *heapstartsize; char const *heapgrowthlimit; char const *heapsize; char const *heapminfree; char const *heapmaxfree; +char const *heaptargetutilization; -void property_override(char const prop[], char const value[]) +void check_device() { - prop_info *pi; + struct sysinfo sys; - pi = (prop_info*) __system_property_find(prop); - if (pi) + sysinfo(&sys); + + if (sys.totalram > 5072ull * 1024 * 1024) { + // from - phone-xhdpi-6144-dalvik-heap.mk + heapstartsize = "16m"; + heapgrowthlimit = "256m"; + heapsize = "512m"; + heaptargetutilization = "0.5"; + heapminfree = "8m"; + heapmaxfree = "32m"; + } else if (sys.totalram > 3072ull * 1024 * 1024) { + // from - phone-xxhdpi-4096-dalvik-heap.mk + heapstartsize = "8m"; + heapgrowthlimit = "256m"; + heapsize = "512m"; + heaptargetutilization = "0.6"; + heapminfree = "8m"; + heapmaxfree = "16m"; + } else { + // from - phone-xhdpi-2048-dalvik-heap.mk + heapstartsize = "8m"; + heapgrowthlimit = "192m"; + heapsize = "512m"; + heaptargetutilization = "0.75"; + heapminfree = "512k"; + heapmaxfree = "8m"; + } +} + +void property_override(char const prop[], char const value[], bool add = true) +{ + auto pi = (prop_info *) __system_property_find(prop); + + if (pi != nullptr) { __system_property_update(pi, value, strlen(value)); - else + } else if (add) { __system_property_add(prop, strlen(prop), value, strlen(value)); + } } void property_override_dual(char const system_prop[], @@ -118,8 +149,16 @@ void vendor_load_persist_properties() } void vendor_load_properties() { - property_override("ro.build.description", "xiaomi/wayne/wayne:8.1.0/OPM1.171019.011/V9.5.11.0.ODCCNFA:user/release-keys"); - property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "xiaomi/wayne/wayne:8.1.0/OPM1.171019.011/V9.5.11.0.ODCCNFA:user/release-keys"); + check_device(); + + property_override("dalvik.vm.heapstartsize", heapstartsize); + property_override("dalvik.vm.heapgrowthlimit", heapgrowthlimit); + property_override("dalvik.vm.heapsize", heapsize); + property_override("dalvik.vm.heaptargetutilization", heaptargetutilization); + property_override("dalvik.vm.heapminfree", heapminfree); + property_override("dalvik.vm.heapmaxfree", heapmaxfree); + + property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "xiaomi/wayne/wayne:8.1.0/OPM1.171019.011/V9.5.11.0.ODCCNFA:user/release-keys"); std::string product = GetProperty("ro.product.vendor.device", ""); if (product.find("whyred") != std::string::npos)