From c0ea446532398e9569ee984e66b26212acd777db Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Thu, 10 Oct 2019 23:04:22 +0200 Subject: [PATCH] msm8974-common: init: Override everything ^.^ Change-Id: If09eed5bf254a386631327ea19e21d42366fb08f --- init/init_msm8974.cpp | 32 +++++++++++++++++++++++--------- init/init_msm8974.h | 5 ++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/init/init_msm8974.cpp b/init/init_msm8974.cpp index 6890732..eb70600 100644 --- a/init/init_msm8974.cpp +++ b/init/init_msm8974.cpp @@ -28,6 +28,8 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #include @@ -37,6 +39,17 @@ using android::init::property_set; +// copied from build/tools/releasetools/ota_from_target_files.py +// but with "." at the end and empty entry +std::vector ro_product_props_default_source_order = { + "", + "product.", + "product_services.", + "odm.", + "vendor.", + "system.", +}; + void set_rild_libpath(char const variant[]) { std::string libpath("/system/vendor/lib/libsec-ril."); @@ -76,20 +89,21 @@ void gsm_properties(const char default_network[], property_set("telephony.lteOnGsmDevice", "1"); } -void property_override(char const prop[], char const value[]) +void property_override(char const prop[], char const value[], bool add) { - prop_info *pi; + auto pi = (prop_info *) __system_property_find(prop); - pi = (prop_info*) __system_property_find(prop); - if (pi) + if (pi != nullptr) { __system_property_update(pi, value, strlen(value)); - else + } else if (add) { __system_property_add(prop, strlen(prop), value, strlen(value)); + } } -void property_override_dual(char const system_prop[], - char const vendor_prop[], char const value[]) +void set_ro_product_prop(char const prop[], char const value[]) { - property_override(system_prop, value); - property_override(vendor_prop, value); + for (const auto &source : ro_product_props_default_source_order) { + auto prop_name = "ro.product." + source + prop; + property_override(prop_name.c_str(), value, false); + } } diff --git a/init/init_msm8974.h b/init/init_msm8974.h index 53085af..df4bc1f 100644 --- a/init/init_msm8974.h +++ b/init/init_msm8974.h @@ -39,8 +39,7 @@ void cdma_properties(char const operator_alpha[], void gsm_properties(char const default_network[], char const rild_lib_variant[]); void init_target_properties(); -void property_override(char const prop[], char const value[]); -void property_override_dual(char const system_prop[], - char const vendor_prop[], char const value[]); +void property_override(char const prop[], char const value[], bool add=false); +void set_ro_product_prop(char const prop[], char const value[]); #endif /* __INIT_MSM8974__H__ */