sm6250-common: init: split up functionality into separate static library

So we can include it again in device-specific tree.
This commit is contained in:
Demon000 2020-08-15 01:23:59 +03:00
parent 8068c2a96f
commit 3b12ba11d0
4 changed files with 99 additions and 57 deletions

View File

@ -14,14 +14,28 @@
// limitations under the License. // 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 { cc_library_static {
name: "libinit_xiaomi_sm6250", name: "libinit_xiaomi_sm6250",
recovery_available: true, recovery_available: true,
srcs: [ srcs: [
"init.cpp" "init.cpp"
], ],
include_dirs: [ whole_static_libs: [
"system/core/base/include", "libinit_xiaomi_sm6250_common"
"system/core/init"
] ]
} }

View File

@ -0,0 +1,6 @@
#ifndef __INIT_COMMON__H__
#define __INIT_COMMON__H__
void load_common_properties();
#endif

View File

@ -14,61 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include <cstdlib> #include "init_common.h"
#include <fstream>
#include <string.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <android-base/properties.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#include "vendor_init.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() { void vendor_load_properties() {
load_dalvik_properties(); load_common_properties();
} }

74
init/init_common.cpp Normal file
View File

@ -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 <cstdlib>
#include <fstream>
#include <string.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <android-base/properties.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#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();
}