diff options
author | Davide Garberi <dade.garberi@gmail.com> | 2021-10-07 10:17:47 +0200 |
---|---|---|
committer | Davide Garberi <dade.garberi@gmail.com> | 2021-10-19 15:09:38 +0200 |
commit | 663d1fb15b06572e677f9aa7bb59136d903f6e76 (patch) | |
tree | 5d25ab409d380843536179af5e0571d5e0892ba3 /init/init_msm8996.cpp | |
parent | 43be610d8f65ce9edad4213fc88dbf4f61deb23d (diff) |
msm8996-common: Move oem unlock prop set to libinit
* Since eleven the property wouldn't get its new context anymore, so work around that
Change-Id: If2f987dd28e1423f53460c65aaa6c03568d94eba
Diffstat (limited to 'init/init_msm8996.cpp')
-rw-r--r-- | init/init_msm8996.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/init/init_msm8996.cpp b/init/init_msm8996.cpp index bdaaaa8..d9b087a 100644 --- a/init/init_msm8996.cpp +++ b/init/init_msm8996.cpp @@ -32,6 +32,8 @@ #include <sys/sysinfo.h> #include <android-base/properties.h> +#include <android-base/file.h> +#include <android-base/strings.h> #include "property_service.h" #include "vendor_init.h" @@ -39,6 +41,9 @@ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #include <sys/_system_properties.h> +using android::base::ReadFileToString; +using android::base::Split; + char const *heapminfree; char const *heapmaxfree; @@ -70,9 +75,35 @@ void property_override(char const prop[], char const value[], bool add = true) } } +void import_kernel_cmdline(const std::function<void(const std::string&, const std::string&)>& fn) { + std::string cmdline; + android::base::ReadFileToString("/proc/cmdline", &cmdline); + + for (const auto& entry : android::base::Split(android::base::Trim(cmdline), " ")) { + std::vector<std::string> pieces = android::base::Split(entry, "="); + if (pieces.size() == 2) { + fn(pieces[0], pieces[1]); + } + } +} + +static void init_setup_lock(const std::string& key, const std::string& value) +{ + if (key.empty()) return; + + if (key == "androidboot.lock") { + if (value.find("unlocked") != std::string::npos) { + property_override("ro.oem_unlock_supported", "0"); + } else { + property_override("ro.oem_unlock_supported", "1"); + } + } +} + void vendor_load_properties() { check_device(); + import_kernel_cmdline(init_setup_lock); property_override("dalvik.vm.heapstartsize", "8m"); property_override("dalvik.vm.heapgrowthlimit", "256m"); |