mirror of
https://github.com/Evolution-X-Devices/device_xiaomi_rosemary
synced 2026-01-27 13:35:09 +00:00
rosemary: init: override dalvik heap config based on total RAM
Change-Id: I5ff7bdc9ab610415093ff6535c34f0013154b8cf
This commit is contained in:
committed by
Matsvei Niaverau
parent
0c1f0ef04a
commit
984575d584
@@ -67,6 +67,10 @@ BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
|
||||
BOARD_KERNEL_CMDLINE := bootopt=64S3,32N2,64N2
|
||||
BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive
|
||||
|
||||
# Init
|
||||
TARGET_INIT_VENDOR_LIB := //$(DEVICE_PATH):libinit_xiaomi_rosemary
|
||||
TARGET_RECOVERY_DEVICE_MODULES := libinit_xiaomi_rosemary
|
||||
|
||||
# Kernel
|
||||
TARGET_KERNEL_ARCH := arm64
|
||||
TARGET_KERNEL_HEADER_ARCH := arm64
|
||||
|
||||
27
init/Android.bp
Normal file
27
init/Android.bp
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
cc_library_static {
|
||||
name: "libinit_xiaomi_rosemary",
|
||||
recovery_available: true,
|
||||
srcs: [
|
||||
"init.cpp"
|
||||
],
|
||||
include_dirs: [
|
||||
"system/core/base/include",
|
||||
"system/core/init"
|
||||
]
|
||||
}
|
||||
83
init/init.cpp
Normal file
83
init/init.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 "vendor_init.h"
|
||||
#include "property_service.h"
|
||||
|
||||
using android::base::GetProperty;
|
||||
using android::init::property_set;
|
||||
|
||||
char const *heapstartsize;
|
||||
char const *heapgrowthlimit;
|
||||
char const *heapsize;
|
||||
char const *heapminfree;
|
||||
char const *heapmaxfree;
|
||||
char const *heaptargetutilization;
|
||||
|
||||
void check_device()
|
||||
{
|
||||
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 {
|
||||
// from - phone-xhdpi-2048-dalvik-heap.mk
|
||||
heapstartsize = "8m";
|
||||
heapgrowthlimit = "192m";
|
||||
heapsize = "512m";
|
||||
heaptargetutilization = "0.75";
|
||||
heapminfree = "512k";
|
||||
heapmaxfree = "8m";
|
||||
}
|
||||
}
|
||||
|
||||
void vendor_load_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", heaptargetutilization);
|
||||
property_set("dalvik.vm.heapminfree", heapminfree);
|
||||
property_set("dalvik.vm.heapmaxfree", heapmaxfree);
|
||||
}
|
||||
Reference in New Issue
Block a user