From 75777bf8c18c351995737a1392c86567efebd3c4 Mon Sep 17 00:00:00 2001 From: SamarV-121 Date: Thu, 8 Jul 2021 09:26:14 +0530 Subject: [PATCH] universal7885: init: Set NFC sku property on supported variants Change-Id: I30e4f0188c8731e0b3b76ab58ec365808eec96d5 Signed-off-by: SamarV-121 --- BoardConfigCommon.mk | 3 ++ init/Android.bp | 24 +++++++++++++++ init/init_universal7904.cpp | 60 +++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 init/Android.bp create mode 100644 init/init_universal7904.cpp diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 77d100f..f32cadf 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -43,6 +43,9 @@ BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 # Include TARGET_SPECIFIC_HEADER_PATH := $(COMMON_PATH)/include +# Init +TARGET_INIT_VENDOR_LIB := //$(COMMON_PATH):libinit_universal7904 + # Kernel BOARD_KERNEL_IMAGE_NAME := Image BOARD_KERNEL_BASE := 0x10000000 diff --git a/init/Android.bp b/init/Android.bp new file mode 100644 index 0000000..6a34f38 --- /dev/null +++ b/init/Android.bp @@ -0,0 +1,24 @@ +// Copyright (C) 2021 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_universal7904", + recovery_available: true, + shared_libs: ["libbase"], + srcs: ["init_universal7904.cpp"], + include_dirs: [ + "system/core/base/include", + "system/core/init" + ] +} diff --git a/init/init_universal7904.cpp b/init/init_universal7904.cpp new file mode 100644 index 0000000..3fd96e0 --- /dev/null +++ b/init/init_universal7904.cpp @@ -0,0 +1,60 @@ +/* + Copyright (c) 2021, The LineageOS Project + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of The Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include + +#include +#include + +#include "property_service.h" +#include "vendor_init.h" + +using android::base::GetProperty; +using std::string; + +void property_override(char const prop[], char const value[], bool add = true) { + prop_info *pi; + + pi = (prop_info*) __system_property_find(prop); + if (pi) + __system_property_update(pi, value, strlen(value)); + else if (add) + __system_property_add(prop, strlen(prop), value, strlen(value)); +} + +void vendor_load_properties() { + string model; + + model = GetProperty("ro.boot.product.model", ""); + + if (model == "SM-M205FN" || model == "SM-A305FN" || model == "SM-A405FN" || model == "SM-A405FM") { + property_override("ro.boot.product.hardware.sku", "NFC"); + } +}