From 799d86bb5247cfafb11030c43408714e6efb8b32 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Sun, 3 Jul 2022 18:57:52 +0800 Subject: [PATCH] sm6225-common: Add init extension to override ro.carrier Change-Id: I82ec6b0d2293dc13524660fd0e2539f08ced2f9f --- BoardConfigCommon.mk | 3 +++ libinit/Android.bp | 13 +++++++++++++ libinit/init_sm6225.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 libinit/Android.bp create mode 100644 libinit/init_sm6225.cpp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index ee5db64..b0a5163 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -66,6 +66,9 @@ DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml DEVICE_MATRIX_FILE := $(COMMON_PATH)/compatibility_matrix.xml ODM_MANIFEST_FILES := $(COMMON_PATH)/manifest-qva.xml +# Init +TARGET_INIT_VENDOR_LIB := //$(COMMON_PATH):libinit_sm6225 + # Kernel BOARD_BOOT_HEADER_VERSION := 3 BOARD_INCLUDE_DTB_IN_BOOTIMG := true diff --git a/libinit/Android.bp b/libinit/Android.bp new file mode 100644 index 0000000..173e0b5 --- /dev/null +++ b/libinit/Android.bp @@ -0,0 +1,13 @@ +// +// Copyright (C) 2022 The LineageOS Project +// +// SPDX-License-Identifier: Apache-2.0 +// + +cc_library_static { + name: "libinit_sm6225", + srcs: ["init_sm6225.cpp"], + recovery_available: true, + include_dirs: ["system/core/init"], + shared_libs: ["libbase"] +} diff --git a/libinit/init_sm6225.cpp b/libinit/init_sm6225.cpp new file mode 100644 index 0000000..4a2eca6 --- /dev/null +++ b/libinit/init_sm6225.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2022 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include + +#include "vendor_init.h" + +using android::base::GetProperty; + +namespace { +void PropertyOverride(const std::string& name, const std::string& value, bool add = true) { + auto pi = const_cast(__system_property_find(name.c_str())); + + if (pi != nullptr) { + __system_property_update(pi, value.c_str(), value.size()); + } else if (add) { + __system_property_add(name.c_str(), name.size(), value.c_str(), value.size()); + } +} +}; // anonymous namespace + +void vendor_load_properties() { + std::string value = GetProperty("ro.boot.carrier", ""); + if (!value.empty()) PropertyOverride("ro.carrier", value); +}