mirror of
https://github.com/PixelExperience-Devices/device_xiaomi_miatoll.git
synced 2025-07-01 08:19:54 +09:00
sm6250-common: Initial variant handler libinit
* This libinit has been made to commonize device variants props handling [dereference23: Adapt for Xiaomi SM6250] Signed-off-by: Alexander Winkowski <dereference23@outlook.com> Change-Id: Iab68ff451ab1d6e861fb4cda4ef07fad3123ecde
This commit is contained in:
committed by
Alexander Winkowski
parent
223d20e8cd
commit
27c7899680
42
libinit/libinit_utils.cpp
Normal file
42
libinit/libinit_utils.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user