From 3b12ba11d07c9d9f9ad20c6ac5c75cc2ea3202c8 Mon Sep 17 00:00:00 2001 From: Demon000 Date: Sat, 15 Aug 2020 01:23:59 +0300 Subject: [PATCH] sm6250-common: init: split up functionality into separate static library So we can include it again in device-specific tree. --- init/Android.bp | 20 +++++++++-- init/include/init_common.h | 6 ++++ init/init.cpp | 56 ++--------------------------- init/init_common.cpp | 74 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 57 deletions(-) create mode 100644 init/include/init_common.h create mode 100644 init/init_common.cpp diff --git a/init/Android.bp b/init/Android.bp index 200b9e1..22c6a5a 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -14,14 +14,28 @@ // limitations under the License. // +cc_library_static { + name: "libinit_xiaomi_sm6250_common", + recovery_available: true, + srcs: [ + "init_common.cpp" + ], + include_dirs: [ + "system/core/base/include", + "system/core/init" + ], + export_include_dirs: [ + "include" + ] +} + cc_library_static { name: "libinit_xiaomi_sm6250", recovery_available: true, srcs: [ "init.cpp" ], - include_dirs: [ - "system/core/base/include", - "system/core/init" + whole_static_libs: [ + "libinit_xiaomi_sm6250_common" ] } diff --git a/init/include/init_common.h b/init/include/init_common.h new file mode 100644 index 0000000..f5602ce --- /dev/null +++ b/init/include/init_common.h @@ -0,0 +1,6 @@ +#ifndef __INIT_COMMON__H__ +#define __INIT_COMMON__H__ + +void load_common_properties(); + +#endif diff --git a/init/init.cpp b/init/init.cpp index 170adae..c7efaba 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -14,61 +14,9 @@ * limitations under the License. */ -#include -#include -#include -#include -#include - -#include -#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ -#include - +#include "init_common.h" #include "vendor_init.h" -#include "property_service.h" - -using android::base::GetProperty; -using android::init::property_set; - -void load_dalvik_properties() { - char const *heapstartsize; - char const *heapgrowthlimit; - char const *heapsize; - char const *heapminfree; - char const *heapmaxfree; - char const *heaptargetutilization; - struct sysinfo sys; - - sysinfo(&sys); - - if (sys.totalram >= 5ull * 1024 * 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 >= 3ull * 1024 * 1024 * 1024) { - // from - phone-xhdpi-4096-dalvik-heap.mk - heapstartsize = "8m"; - heapgrowthlimit = "192m"; - heapsize = "512m"; - heaptargetutilization = "0.6"; - heapminfree = "8m"; - heapmaxfree = "16m"; - } else { - return; - } - - property_set("dalvik.vm.heapstartsize", heapstartsize); - property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit); - property_set("dalvik.vm.heapsize", heapsize); - property_set("dalvik.vm.heaptargetutilization", heaptargetutilization); - property_set("dalvik.vm.heapminfree", heapminfree); - property_set("dalvik.vm.heapmaxfree", heapmaxfree); -} void vendor_load_properties() { - load_dalvik_properties(); + load_common_properties(); } diff --git a/init/init_common.cpp b/init/init_common.cpp new file mode 100644 index 0000000..92e9b67 --- /dev/null +++ b/init/init_common.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include + +#include "init_common.h" +#include "property_service.h" + +using android::base::GetProperty; +using android::init::property_set; + +void load_dalvik_properties() { + char const *heapstartsize; + char const *heapgrowthlimit; + char const *heapsize; + char const *heapminfree; + char const *heapmaxfree; + char const *heaptargetutilization; + struct sysinfo sys; + + sysinfo(&sys); + + if (sys.totalram >= 5ull * 1024 * 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 >= 3ull * 1024 * 1024 * 1024) { + // from - phone-xhdpi-4096-dalvik-heap.mk + heapstartsize = "8m"; + heapgrowthlimit = "192m"; + heapsize = "512m"; + heaptargetutilization = "0.6"; + heapminfree = "8m"; + heapmaxfree = "16m"; + } else { + return; + } + + property_set("dalvik.vm.heapstartsize", heapstartsize); + property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit); + property_set("dalvik.vm.heapsize", heapsize); + property_set("dalvik.vm.heaptargetutilization", heaptargetutilization); + property_set("dalvik.vm.heapminfree", heapminfree); + property_set("dalvik.vm.heapmaxfree", heapmaxfree); +} + +void load_common_properties() { + load_dalvik_properties(); +}