From 261a78ac478bba7b530ee73de1c01c875e60e6bc Mon Sep 17 00:00:00 2001 From: erwinabs Date: Sun, 19 Nov 2023 01:30:26 +0700 Subject: [PATCH] ginkgo: upstream Change-Id: I001ae78088eb46a456f239ff2df7af93d4f12c99 --- BoardConfig.mk | 9 ++- init/Android.bp | 14 +++++ init/init_ginkgo.cpp | 60 +++++++++++++++++++ recovery/root/init.recovery.qcom.rc | 3 + .../android.hidl.allocator@1.0-service.xml | 11 ++++ .../android.system.keystore2-service.xml | 12 ++-- .../android.system.suspend@1.0-service.xml | 11 ++++ system.prop | 3 - 8 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 init/Android.bp create mode 100644 init/init_ginkgo.cpp create mode 100644 recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml create mode 100644 recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml diff --git a/BoardConfig.mk b/BoardConfig.mk index f594647..cf09c74 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -89,6 +89,7 @@ BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 # System as root BOARD_BUILD_SYSTEM_ROOT_IMAGE := true +TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/recovery/root/system/etc/recovery.fstab # File systems TARGET_USERIMAGES_USE_EXT4 := true @@ -98,6 +99,10 @@ TARGET_USERIMAGES_USE_F2FS := true BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 TARGET_COPY_OUT_VENDOR := vendor +# Init +TARGET_INIT_VENDOR_LIB := //$(DEVICE_PATH):libinit_ginkgo +TARGET_RECOVERY_DEVICE_MODULES := libinit_ginkgo + # Encryption BOARD_USES_METADATA_PARTITION := true TW_INCLUDE_FBE_METADATA_DECRYPT := true @@ -112,7 +117,7 @@ PRODUCT_ENFORCE_VINTF_MANIFEST := true # Extras BOARD_SUPPRESS_SECURE_ERASE := true -#TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop +TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop # Recovery BOARD_HAS_LARGE_FILESYSTEM := true @@ -124,8 +129,6 @@ TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES += \ $(TARGET_OUT_SHARED_LIBRARIES)/libion.so \ $(TARGET_OUT_SHARED_LIBRARIES)/libxml2.so -#TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/recovery/root/system/etc/recovery.fstab - # TWRP specific build flags RECOVERY_SDCARD_ON_DATA := true TARGET_RECOVERY_QCOM_RTC_FIX := true diff --git a/init/Android.bp b/init/Android.bp new file mode 100644 index 0000000..022f278 --- /dev/null +++ b/init/Android.bp @@ -0,0 +1,14 @@ +cc_library_static { + name: "libinit_ginkgo", + header_libs: [ + "libbase_headers", + ], + cflags: [ + "-Wall", + ], + static_libs: [ + "libbase", + ], + srcs: ["init_ginkgo.cpp"], + recovery_available: true, +} diff --git a/init/init_ginkgo.cpp b/init/init_ginkgo.cpp new file mode 100644 index 0000000..00a7dc0 --- /dev/null +++ b/init/init_ginkgo.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include + +using android::base::GetProperty; + +void property_override(const std::string& name, const std::string& value) +{ + size_t valuelen = value.size(); + + prop_info* pi = (prop_info*) __system_property_find(name.c_str()); + if (pi != nullptr) { + __system_property_update(pi, value.c_str(), valuelen); + } + else { + int rc = __system_property_add(name.c_str(), name.size(), value.c_str(), valuelen); + if (rc < 0) { + LOG(ERROR) << "property_set(\"" << name << "\", \"" << value << "\") failed: " + << "__system_property_add failed"; + } + } +} + +void model_property_override(const std::string& device, const std::string& model) +{ + property_override("ro.product.device", device); + property_override("ro.product.odm.device", device); + property_override("ro.product.system.device", device); + property_override("ro.product.vendor.device", device); + property_override("ro.build.product", device); + property_override("ro.product.name", device); + property_override("ro.product.odm.name", device); + property_override("ro.product.product.device", device); + property_override("ro.product.product.name", device); + property_override("ro.product.system.name", device); + property_override("ro.product.system_ext.device", device); + property_override("ro.product.system_ext.name", device); + property_override("ro.product.vendor.name", device); + property_override("ro.product.model", model); + property_override("ro.product.odm.model", model); + property_override("ro.product.system.model", model); + property_override("ro.product.vendor.model", model); + property_override("ro.product.product.model", model); + property_override("ro.product.system_ext.model", model); +} + +void vendor_load_properties() { + const std::string hwc = GetProperty("ro.boot.hwc", ""); + if (hwc == "Global_B") { + model_property_override("willow", "Redmi Note 8T"); + } else if (hwc == "Global") { + model_property_override("ginkgo", "Redmi Note 8"); + } +} diff --git a/recovery/root/init.recovery.qcom.rc b/recovery/root/init.recovery.qcom.rc index a225fdf..e7ed1f6 100644 --- a/recovery/root/init.recovery.qcom.rc +++ b/recovery/root/init.recovery.qcom.rc @@ -27,6 +27,9 @@ import /init.recovery.qcom_decrypt.rc +on init +setprop prepdecrypt.loglevel 2 + on fs wait /dev/block/platform/soc/${ro.boot.bootdevice} symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice diff --git a/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml b/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml new file mode 100644 index 0000000..5218241 --- /dev/null +++ b/recovery/root/system/etc/vintf/manifest/android.hidl.allocator@1.0-service.xml @@ -0,0 +1,11 @@ + + + android.hidl.allocator + hwbinder + 1.0 + + IAllocator + ashmem + + + diff --git a/recovery/root/system/etc/vintf/manifest/android.system.keystore2-service.xml b/recovery/root/system/etc/vintf/manifest/android.system.keystore2-service.xml index 3a7a7a3..6b8d0cb 100644 --- a/recovery/root/system/etc/vintf/manifest/android.system.keystore2-service.xml +++ b/recovery/root/system/etc/vintf/manifest/android.system.keystore2-service.xml @@ -1,7 +1,9 @@ - - android.system.keystore2 - IKeystoreService + + + android.system.keystore2 + + IKeystoreService default - + + diff --git a/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml b/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml new file mode 100644 index 0000000..9f06ae3 --- /dev/null +++ b/recovery/root/system/etc/vintf/manifest/android.system.suspend@1.0-service.xml @@ -0,0 +1,11 @@ + + + android.system.suspend + hwbinder + 1.0 + + ISystemSuspend + default + + + diff --git a/system.prop b/system.prop index 669056f..2fb7db4 100644 --- a/system.prop +++ b/system.prop @@ -5,6 +5,3 @@ persist.sys.isUsbOtgEnabled=true vendor.gatekeeper.disable_spu=true ro.boot.avb_version=1.0 ro.boot.vbmeta.avb_version=1.0 -ro.crypto.volume.filenames_mode=aes-256-cts -ro.crypto.allow_encrypt_override=true -ro.hardware.keystore_desede=true