aboutsummaryrefslogtreecommitdiff
path: root/libinit
diff options
context:
space:
mode:
Diffstat (limited to 'libinit')
-rw-r--r--libinit/Android.bp24
-rw-r--r--libinit/include/libinit_dalvik_heap.h23
-rw-r--r--libinit/include/libinit_utils.h18
-rw-r--r--libinit/include/libinit_variant.h31
-rw-r--r--libinit/init_xiaomi_holi.cpp13
-rw-r--r--libinit/init_xiaomi_veux.cpp54
-rw-r--r--libinit/libinit_dalvik_heap.cpp67
-rw-r--r--libinit/libinit_utils.cpp73
-rw-r--r--libinit/libinit_variant.cpp49
9 files changed, 336 insertions, 16 deletions
diff --git a/libinit/Android.bp b/libinit/Android.bp
index 59a0fa8..d3ed028 100644
--- a/libinit/Android.bp
+++ b/libinit/Android.bp
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2021 The LineageOS Project
+// Copyright (C) 2022 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
@@ -7,7 +7,27 @@
cc_library_static {
name: "init_xiaomi_veux",
srcs: ["init_xiaomi_veux.cpp"],
- whole_static_libs: ["//device/xiaomi/sm6375-common:libinit_xiaomi_holi"],
+ whole_static_libs: ["//device/xiaomi/veux:libinit_xiaomi_holi"],
include_dirs: ["system/core/init"],
recovery_available: true,
}
+
+cc_library_static {
+ name: "libinit_xiaomi_holi",
+ srcs: [
+ "libinit_dalvik_heap.cpp",
+ "libinit_variant.cpp",
+ "libinit_utils.cpp",
+ ],
+ whole_static_libs: ["libbase"],
+ export_include_dirs: ["include"],
+ recovery_available: true,
+}
+
+cc_library_static {
+ name: "init_xiaomi_holi",
+ srcs: ["init_xiaomi_holi.cpp"],
+ whole_static_libs: ["libinit_xiaomi_holi"],
+ include_dirs: ["system/core/init"],
+ recovery_available: true,
+} \ No newline at end of file
diff --git a/libinit/include/libinit_dalvik_heap.h b/libinit/include/libinit_dalvik_heap.h
new file mode 100644
index 0000000..caea339
--- /dev/null
+++ b/libinit/include/libinit_dalvik_heap.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef LIBINIT_DALVIK_HEAP_H
+#define LIBINIT_DALVIK_HEAP_H
+
+#include <string>
+
+typedef struct dalvik_heap_info {
+ std::string heapstartsize;
+ std::string heapgrowthlimit;
+ std::string heapsize;
+ std::string heapminfree;
+ std::string heapmaxfree;
+ std::string heaptargetutilization;
+} dalvik_heap_info_t;
+
+void set_dalvik_heap(void);
+
+#endif // LIBINIT_DALVIK_HEAP_H
diff --git a/libinit/include/libinit_utils.h b/libinit/include/libinit_utils.h
new file mode 100644
index 0000000..6c42883
--- /dev/null
+++ b/libinit/include/libinit_utils.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef LIBINIT_UTILS_H
+#define LIBINIT_UTILS_H
+
+#include <string>
+
+void property_override(std::string prop, std::string value, bool add = true);
+
+void set_ro_build_prop(const std::string &prop, const std::string &value, bool product = false);
+
+std::string fingerprint_to_description(std::string fingerprint);
+
+#endif // LIBINIT_UTILS_H
diff --git a/libinit/include/libinit_variant.h b/libinit/include/libinit_variant.h
new file mode 100644
index 0000000..f0b3222
--- /dev/null
+++ b/libinit/include/libinit_variant.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef LIBINIT_VARIANT_H
+#define LIBINIT_VARIANT_H
+
+#include <string>
+#include <vector>
+
+typedef struct variant_info {
+ std::string hwc_value;
+ std::string model_value;
+
+ std::string brand;
+ std::string device;
+ std::string marketname;
+ std::string model;
+ std::string name;
+ std::string build_fingerprint;
+
+ bool nfc;
+} variant_info_t;
+
+void search_variant(const std::vector<variant_info_t> variants);
+
+void set_variant_props(const variant_info_t variant);
+
+#endif // LIBINIT_VARIANT_H
diff --git a/libinit/init_xiaomi_holi.cpp b/libinit/init_xiaomi_holi.cpp
new file mode 100644
index 0000000..22cb31e
--- /dev/null
+++ b/libinit/init_xiaomi_holi.cpp
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <libinit_dalvik_heap.h>
+
+#include "vendor_init.h"
+
+void vendor_load_properties() {
+ set_dalvik_heap();
+}
diff --git a/libinit/init_xiaomi_veux.cpp b/libinit/init_xiaomi_veux.cpp
index 2324f05..98bbb7c 100644
--- a/libinit/init_xiaomi_veux.cpp
+++ b/libinit/init_xiaomi_veux.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 The LineageOS Project
+ * Copyright (C) 2022 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,95 +10,121 @@
#include "vendor_init.h"
static const variant_info_t veux_global_info = {
+ .hwc_value = "Global",
.model_value = "S88006AA1",
- .sku_value = "",
.brand = "Redmi",
.device = "veux",
.marketname = "Redmi Note 11 Pro 5G",
.model = "2201116SG",
.name = "veux_global",
- .build_fingerprint = "Redmi/veux_global/veux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "Redmi/veux_global/veux:11/RKQ1.211001.001/V13.0.14.0.RKCMIXM:user/release-keys",
.nfc = true,
};
+static const variant_info_t veux_in_info = {
+ .hwc_value = "India",
+ .model_value = "S88006AA1",
+
+ .brand = "Redmi",
+ .device = "veux",
+ .marketname = "Redmi Note 11 Pro 5G",
+ .model = "2201116SG",
+ .name = "veux_in",
+ .build_fingerprint = "Redmi/veux_in/veux:11/RKQ1.211001.001/V13.0.4.0.RKCINXM:user/release-keys",
+};
+
static const variant_info_t veux_info = {
+ .hwc_value = "CN",
.model_value = "S88007AA1",
- .sku_value = "",
.brand = "Redmi",
.device = "veux",
.marketname = "Redmi Note 11E Pro",
.model = "2201116SC",
.name = "veux",
- .build_fingerprint = "Redmi/veux/veux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "Redmi/veux/veux:11/RKQ1.211001.001/V13.0.7.0.RKCCNXM:user/release-keys",
.nfc = true,
};
static const variant_info_t peux_in_info = {
+ .hwc_value = "",
.model_value = "S88007EA1",
- .sku_value = "",
.brand = "Redmi",
.device = "peux",
.marketname = "Redmi Note 11 Pro+ 5G",
.model = "2201116SI",
.name = "peux_in",
- .build_fingerprint = "Redmi/peux_in/peux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "Redmi/peux_in/peux:11/RKQ1.211001.001/V13.0.4.0.RKCINXM:user/release-keys",
};
static const variant_info_t veux_jp_info = {
+ .hwc_value = "",
.model_value = "S88008BA1",
- .sku_value = "",
.brand = "Redmi",
.device = "veux",
.marketname = "Redmi Note 11 Pro 5G",
.model = "2201116SR",
.name = "veux_jp",
- .build_fingerprint = "Redmi/veux_jp/veux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "Redmi/veux/veux:11/RKQ1.211001.001/V13.0.2.0.RKCJPXM:user/release-keys",
.nfc = true,
};
static const variant_info_t veux_p_global_info = {
+ .hwc_value = "Global",
.model_value = "S88106BA1",
- .sku_value = "",
.brand = "POCO",
.device = "veux",
.marketname = "POCO X4 Pro 5G",
.model = "2201116PG",
.name = "veux_p_global",
- .build_fingerprint = "POCO/veux_p_global/veux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "POCO/veux_p_global/veux:11/RKQ1.211001.001/V13.0.14.0.RKCMIXM:user/release-keys",
.nfc = true,
};
+static const variant_info_t veux_p_in_info = {
+ .hwc_value = "India",
+ .model_value = "S88106BA1",
+
+ .brand = "POCO",
+ .device = "veux",
+ .marketname = "POCO X4 Pro 5G",
+ .model = "2201116PG",
+ .name = "veux_p_in",
+ .build_fingerprint = "POCO/veux_p_in/veux:11/RKQ1.211001.001/V13.0.4.0.RKCINXM:user/release-keys",
+};
+
static const variant_info_t peux_p_in_info = {
+ .hwc_value = "India",
.model_value = "S88107BA1",
- .sku_value = "",
.brand = "POCO",
.device = "veux",
.marketname = "POCO X4 Pro 5G",
.model = "2201116PI",
.name = "peux_p_in",
- .build_fingerprint = "POCO/peux_p_in/peux:11/RKQ1.211001.001/V13.0.10.0.RKCMIXM:user/release-keys",
+ .build_fingerprint = "POCO/peux_p_in/peux:11/RKQ1.211001.001/V13.0.4.0.RKCINXM:user/release-keys",
};
static const std::vector<variant_info_t> variants = {
veux_global_info,
+ veux_in_info,
veux_info,
peux_in_info,
veux_jp_info,
veux_p_global_info,
+ veux_p_in_info,
peux_p_in_info,
};
void vendor_load_properties() {
search_variant(variants);
set_dalvik_heap();
-}
+} \ No newline at end of file
diff --git a/libinit/libinit_dalvik_heap.cpp b/libinit/libinit_dalvik_heap.cpp
new file mode 100644
index 0000000..b3b24ba
--- /dev/null
+++ b/libinit/libinit_dalvik_heap.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <sys/sysinfo.h>
+#include <libinit_utils.h>
+
+#include <libinit_dalvik_heap.h>
+
+#define HEAPSTARTSIZE_PROP "dalvik.vm.heapstartsize"
+#define HEAPGROWTHLIMIT_PROP "dalvik.vm.heapgrowthlimit"
+#define HEAPSIZE_PROP "dalvik.vm.heapsize"
+#define HEAPMINFREE_PROP "dalvik.vm.heapminfree"
+#define HEAPMAXFREE_PROP "dalvik.vm.heapmaxfree"
+#define HEAPTARGETUTILIZATION_PROP "dalvik.vm.heaptargetutilization"
+
+#define GB(b) (b * 1024ull * 1024 * 1024)
+
+static const dalvik_heap_info_t dalvik_heap_info_6144 = {
+ .heapstartsize = "16m",
+ .heapgrowthlimit = "256m",
+ .heapsize = "512m",
+ .heapminfree = "8m",
+ .heapmaxfree = "32m",
+ .heaptargetutilization = "0.5",
+};
+
+static const dalvik_heap_info_t dalvik_heap_info_4096 = {
+ .heapstartsize = "8m",
+ .heapgrowthlimit = "256m",
+ .heapsize = "512m",
+ .heapminfree = "8m",
+ .heapmaxfree = "16m",
+ .heaptargetutilization = "0.6",
+};
+
+static const dalvik_heap_info_t dalvik_heap_info_2048 = {
+ .heapstartsize = "8m",
+ .heapgrowthlimit = "192m",
+ .heapsize = "512m",
+ .heapminfree = "512k",
+ .heapmaxfree = "8m",
+ .heaptargetutilization = "0.75",
+};
+
+void set_dalvik_heap() {
+ struct sysinfo sys;
+ const dalvik_heap_info_t *dhi;
+
+ sysinfo(&sys);
+
+ if (sys.totalram > GB(5))
+ dhi = &dalvik_heap_info_6144;
+ else if (sys.totalram > GB(3))
+ dhi = &dalvik_heap_info_4096;
+ else
+ dhi = &dalvik_heap_info_2048;
+
+ property_override(HEAPSTARTSIZE_PROP, dhi->heapstartsize);
+ property_override(HEAPGROWTHLIMIT_PROP, dhi->heapgrowthlimit);
+ property_override(HEAPSIZE_PROP, dhi->heapsize);
+ property_override(HEAPTARGETUTILIZATION_PROP, dhi->heaptargetutilization);
+ property_override(HEAPMINFREE_PROP, dhi->heapminfree);
+ property_override(HEAPMAXFREE_PROP, dhi->heapmaxfree);
+}
diff --git a/libinit/libinit_utils.cpp b/libinit/libinit_utils.cpp
new file mode 100644
index 0000000..50f5c35
--- /dev/null
+++ b/libinit/libinit_utils.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <sys/_system_properties.h>
+#include <vector>
+
+#include <libinit_utils.h>
+
+void property_override(std::string prop, std::string value, bool add) {
+ auto pi = (prop_info *) __system_property_find(prop.c_str());
+ if (pi != nullptr) {
+ __system_property_update(pi, value.c_str(), value.length());
+ } else if (add) {
+ __system_property_add(prop.c_str(), prop.length(), value.c_str(), value.length());
+ }
+}
+
+std::vector<std::string> ro_props_default_source_order = {
+ "odm.",
+ "product.",
+ "system.",
+ "system_ext.",
+ "vendor.",
+ "",
+};
+
+void set_ro_build_prop(const std::string &prop, const std::string &value, bool product) {
+ std::string prop_name;
+
+ for (const auto &source : ro_props_default_source_order) {
+ if (product)
+ prop_name = "ro.product." + source + prop;
+ else
+ prop_name = "ro." + source + "build." + prop;
+
+ property_override(prop_name, value, true);
+ }
+}
+
+#define FIND_AND_REMOVE(s, delimiter, variable_name) \
+ std::string variable_name = s.substr(0, s.find(delimiter)); \
+ s.erase(0, s.find(delimiter) + delimiter.length());
+
+#define APPEND_STRING(s, to_append) \
+ s.append(" "); \
+ s.append(to_append);
+
+std::string fingerprint_to_description(std::string fingerprint) {
+ std::string delimiter = "/";
+ std::string delimiter2 = ":";
+ std::string build_fingerprint_copy = fingerprint;
+
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter, brand)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter, product)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter2, device)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter, platform_version)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter, build_id)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter2, build_number)
+ FIND_AND_REMOVE(build_fingerprint_copy, delimiter, build_variant)
+ std::string build_version_tags = build_fingerprint_copy;
+
+ std::string description = product + "-" + build_variant;
+ APPEND_STRING(description, platform_version)
+ APPEND_STRING(description, build_id)
+ APPEND_STRING(description, build_number)
+ APPEND_STRING(description, build_version_tags)
+
+ return description;
+}
diff --git a/libinit/libinit_variant.cpp b/libinit/libinit_variant.cpp
new file mode 100644
index 0000000..99babbf
--- /dev/null
+++ b/libinit/libinit_variant.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2022 The LineageOS Project
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <libinit_utils.h>
+
+#include <libinit_variant.h>
+
+using android::base::GetProperty;
+
+
+#define HWC_PROP "ro.boot.hwc"
+#define MODEL_PROP "ro.boot.board_id"
+#define SKU_PROP "ro.boot.product.hardware.sku"
+
+void search_variant(const std::vector<variant_info_t> variants) {
+ std::string hwc_value = GetProperty(HWC_PROP, "");
+ std::string model_value = GetProperty(MODEL_PROP, "");
+
+ for (const auto& variant : variants) {
+ if ((variant.hwc_value == "" || variant.hwc_value == hwc_value) &&
+ (variant.model_value == "" || variant.model_value == model_value)) {
+ set_variant_props(variant);
+ break;
+ }
+ }
+}
+
+void set_variant_props(const variant_info_t variant) {
+ set_ro_build_prop("brand", variant.brand, true);
+ set_ro_build_prop("device", variant.device, true);
+ set_ro_build_prop("marketname", variant.marketname, true);
+ set_ro_build_prop("model", variant.model, true);
+ set_ro_build_prop("name", variant.name, true);
+
+ if (access("/system/bin/recovery", F_OK) != 0) {
+ set_ro_build_prop("fingerprint", variant.build_fingerprint);
+ property_override("ro.bootimage.build.fingerprint", variant.build_fingerprint);
+
+ property_override("ro.build.description", fingerprint_to_description(variant.build_fingerprint));
+ }
+
+ if (variant.nfc)
+ property_override(SKU_PROP, "nfc");
+}