From 8b09473b423eae3cfbe2b8055920463998e7fe21 Mon Sep 17 00:00:00 2001 From: RomanDesigner Date: Fri, 17 Jan 2020 16:25:31 +0300 Subject: [PATCH] Init bringup for Q --- BoardConfigCommon.mk | 4 ++ init/Android.bp | 26 +++++++++++++ init/init_matisse.cpp | 88 ++++++++++++++++++++++++++++++++----------- 3 files changed, 95 insertions(+), 23 deletions(-) create mode 100644 init/Android.bp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index fcdde52..7b5afde 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -69,6 +69,10 @@ BOARD_CACHEIMAGE_PARTITION_SIZE := 314572800 BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2362232012 BOARD_USERDATAIMAGE_PARTITION_SIZE := 12884901888 +# Init +TARGET_INIT_VENDOR_LIB := libinit_matisse +TARGET_RECOVERY_DEVICE_MODULES := libinit_matisse + # Power HAL TARGET_POWERHAL_SET_INTERACTIVE_EXT := $(COMMON_PATH)/power/power_ext.c TARGET_POWERHAL_VARIANT := qcom diff --git a/init/Android.bp b/init/Android.bp new file mode 100644 index 0000000..c75c193 --- /dev/null +++ b/init/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2019 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_matisse", + recovery_available: true, + srcs: ["init_matisse.cpp"], + whole_static_libs: ["libbase"], + include_dirs: [ + "system/core/base/include", + "system/core/init" + ] +} diff --git a/init/init_matisse.cpp b/init/init_matisse.cpp index e12997f..e6a2bff 100755 --- a/init/init_matisse.cpp +++ b/init/init_matisse.cpp @@ -28,61 +28,103 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include +#include +#include +#include +#include +#include #include #include +#include + +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include #include "property_service.h" #include "vendor_init.h" -#include "init_msm8226.h" - using android::base::GetProperty; +using android::base::ReadFileToString; +using android::base::Trim; using android::init::property_set; -void gsm_properties() +// 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 property_override(char const prop[], char const value[], bool add = true) +{ + auto pi = (prop_info *) __system_property_find(prop); + + if (pi != nullptr) { + __system_property_update(pi, value, strlen(value)); + } else if (add) { + __system_property_add(prop, strlen(prop), value, strlen(value)); + } +} + +void set_wifionly() { property_set("ro.carrier", "wifi-only"); property_set("ro.radio.noril", "1"); } -void init_target_properties() +void vendor_load_properties() { - std::string platform = GetProperty("ro.board.platform", ""); - if (platform != ANDROID_TARGET) - return; + const auto set_ro_product_prop = [](const std::string &source, + const std::string &prop, const std::string &value) { + auto prop_name = "ro.product." + source + prop; + property_override(prop_name.c_str(), value.c_str(), false); + }; + std::string bootloader = GetProperty("ro.bootloader", ""); if (bootloader.find("T530NU") == 0) { /* matissewifiue */ - property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "samsung/matissewifiue/matissewifi:5.0.2/LRX22G/T530NUU1BOJ4:user/release-keys"); + for (const auto &source : ro_product_props_default_source_order) { + set_ro_product_prop(source, "fingerprint", "samsung/matissewifiue/matissewifi:5.0.2/LRX22G/T530NUU1BOJ4:user/release-keys"); + set_ro_product_prop(source, "model", "SM-T530NU"); + set_ro_product_prop(source, "device", "matissewifi"); + } property_override("ro.build.description", "matissewifiue-user 5.0.2 LRX22G T530NUU1BOJ4 release-keys"); - property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-T530NU"); - property_override_dual("ro.product.device", "ro.vendor.product.device", "matissewifi"); - gsm_properties(); + set_wifionly(); } else if (bootloader.find("T530XX") == 0) { /* matissewifixx */ - property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "samsung/matissewifixx/matissewifi:5.0.2/LRX22G/T530XXU1BOJ4:user/release-keys"); + for (const auto &source : ro_product_props_default_source_order) { + set_ro_product_prop(source, "fingerprint", "samsung/matissewifixx/matissewifi:5.0.2/LRX22G/T530XXU1BOJ4:user/release-keys"); + set_ro_product_prop(source, "model", "SM-T530"); + set_ro_product_prop(source, "device", "matissewifi"); + } property_override("ro.build.description", "matissewifixx-user 5.0.2 LRX22G T530XXU1BOJ4 release-keys"); - property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-T530"); - property_override_dual("ro.product.device", "ro.vendor.product.device", "matissewifi"); - gsm_properties(); + set_wifionly(); } else if (bootloader.find("T531XX") == 0) { /* matisse3gxx */ - property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "samsung/matisse3gxx/matisse3g:5.0.2/LRX22G/T531XXU1BOE6:user/release-keys"); + for (const auto &source : ro_product_props_default_source_order) { + set_ro_product_prop(source, "fingerprint", "samsung/matisse3gxx/matisse3g:5.0.2/LRX22G/T531XXU1BOE6:user/release-keys"); + set_ro_product_prop(source, "model", "SM-T531"); + set_ro_product_prop(source, "device", "matisse3g"); + } property_override("ro.build.description", "matisse3gxx-user 5.0.2 LRX22G T531XXU1BOE6 release-keys"); - property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-T531"); - property_override_dual("ro.product.device", "ro.vendor.product.device", "matisse3g"); } else if (bootloader.find("T535XX") == 0) { /* matisseltexx */ - property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "samsung/matisseltexx/matisselte:5.0.2/LRX22G/T535XXU1BOL1:user/release-keys"); + for (const auto &source : ro_product_props_default_source_order) { + set_ro_product_prop(source, "fingerprint", "samsung/matisseltexx/matisselte:5.0.2/LRX22G/T535XXU1BOL1:user/release-keys"); + set_ro_product_prop(source, "model", "SM-T535"); + set_ro_product_prop(source, "device", "matisselte"); + } property_override("ro.build.description", "matisseltexx-user 5.0.2 LRX22G T535XXU1BOL1 release-keys"); - property_override_dual("ro.product.model", "ro.vendor.product.model", "SM-T535"); - property_override_dual("ro.product.device", "ro.vendor.product.device", "matisselte"); } else { - gsm_properties(); + set_wifionly(); } std::string device = GetProperty("ro.product.device", "");