diff --git a/blob-patches/HbmSVManager.patch b/bramble/HbmSVManager.patch similarity index 100% rename from blob-patches/HbmSVManager.patch rename to bramble/HbmSVManager.patch diff --git a/bramble/extract-files.py b/bramble/extract-files.py new file mode 100755 index 0000000..b142c49 --- /dev/null +++ b/bramble/extract-files.py @@ -0,0 +1,88 @@ +#!/usr/bin/env -S PYTHONPATH=../../../../tools/extract-utils python3 +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +from extract_utils.extract import extract_fns_user_type +from extract_utils.extract_pixel import ( + extract_pixel_factory_image, + extract_pixel_firmware, + pixel_factory_image_regex, + pixel_firmware_regex, +) +from extract_utils.fixups_blob import ( + blob_fixup, + blob_fixups_user_type, +) +from extract_utils.fixups_lib import ( + lib_fixup_remove, + lib_fixups, + lib_fixups_user_type, +) +from extract_utils.main import ( + ExtractUtils, + ExtractUtilsModule, +) + +namespace_imports = [ + 'hardware/google/interfaces', + 'hardware/google/pixel', + 'hardware/qcom/sm7250/display', + 'hardware/qcom/sm7250/gps', + 'hardware/qcom/wlan/legacy', + 'vendor/qcom/opensource/display', +] + + +def lib_fixup_vendor_suffix(lib: str, partition: str, *args, **kwargs): + return f'{lib}_{partition}' if partition == 'vendor' else None + + +lib_fixups: lib_fixups_user_type = { + **lib_fixups, + ( + 'vendor.qti.hardware.tui_comm@1.0', + 'vendor.qti.imsrtpservice@3.0', + ): lib_fixup_vendor_suffix, + 'libwpa_client': lib_fixup_remove, +} + +blob_fixups: blob_fixups_user_type = { + 'product/etc/felica/common.cfg': blob_fixup() + .patch_file('osaifu-keitai.patch'), + 'product/etc/sysconfig/nexus.xml': blob_fixup() + .regex_replace('qulacomm', 'qualcomm'), + 'system_ext/priv-app/HbmSVManager/HbmSVManager.apk': blob_fixup() + .apktool_patch('HbmSVManager.patch', '-r'), + ( + 'vendor/bin/hw/android.hardware.rebootescrow-service.citadel', + 'vendor/lib64/android.hardware.keymaster@4.1-impl.nos.so', + ): blob_fixup() + .add_needed('libcrypto_shim.so'), + 'vendor/lib64/libgooglecamerahal.so': blob_fixup() + .add_needed('libmeminfo_shim.so'), +} # fmt: skip + +extract_fns: extract_fns_user_type = { + pixel_factory_image_regex: extract_pixel_factory_image, + pixel_firmware_regex: extract_pixel_firmware, +} + +module = ExtractUtilsModule( + 'bramble', + 'google', + device_rel_path='device/google/bramble/bramble', + blob_fixups=blob_fixups, + lib_fixups=lib_fixups, + namespace_imports=namespace_imports, + add_firmware_proprietary_file=True, + extract_fns=extract_fns, +) + +module.add_proprietary_file('proprietary-files-carriersettings.txt') +module.add_proprietary_file('proprietary-files-vendor.txt') + +if __name__ == '__main__': + utils = ExtractUtils.device(module) + utils.run() diff --git a/bramble/osaifu-keitai.patch b/bramble/osaifu-keitai.patch new file mode 100644 index 0000000..83d6d0e --- /dev/null +++ b/bramble/osaifu-keitai.patch @@ -0,0 +1,24 @@ +From aab255f2807cfc460c0dce40decd5554d49c0076 Mon Sep 17 00:00:00 2001 +From: jabashque +Date: Mon, 5 Feb 2024 21:36:03 +0000 +Subject: [PATCH 1/1] Enable Osaifu-Keitai on non-Japanese SKUs + +--- + common.cfg | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/common.cfg b/common.cfg +index 3b78765..00f53cb 100644 +--- a/common.cfg ++++ b/common.cfg +@@ -11,6 +11,5 @@ + 02030001,0 + 02030002,0 + 02030003,intent:#Intent;action=android.settings.NFC_SETTINGS;end +-00000014,content://com.google.android.pixelnfc.provider.DeviceInfoContentProvider/isJapanSku +-00000015,is_japan_sku + 00000016,0001 ++00000018,1 +-- +2.47.0 + diff --git a/proprietary-files-carriersettings.txt b/bramble/proprietary-files-carriersettings.txt similarity index 100% rename from proprietary-files-carriersettings.txt rename to bramble/proprietary-files-carriersettings.txt diff --git a/proprietary-files-vendor.txt b/bramble/proprietary-files-vendor.txt similarity index 99% rename from proprietary-files-vendor.txt rename to bramble/proprietary-files-vendor.txt index aa00d57..acfbbd3 100644 --- a/proprietary-files-vendor.txt +++ b/bramble/proprietary-files-vendor.txt @@ -1009,7 +1009,7 @@ vendor/lib/vendor.qti.hardware.soter@1.0.so vendor/lib/vendor.qti.hardware.trustedui@1.0.so vendor/lib/vendor.qti.hardware.trustedui@1.1.so vendor/lib/vendor.qti.hardware.trustedui@1.2.so -vendor/lib/vendor.qti.hardware.tui_comm@1.0.so;MODULE_SUFFIX=-vendor +vendor/lib/vendor.qti.hardware.tui_comm@1.0.so;MODULE_SUFFIX=_vendor vendor/lib/vendor.qti.hardware.wifidisplaysession@1.0.so vendor/lib/vendor.qti.hardware.wigig.netperftuner@1.0.so vendor/lib/vendor.qti.ims.callcapability@1.0.so @@ -1021,7 +1021,7 @@ vendor/lib/vendor.qti.ims.rcsconfig@1.1.so vendor/lib/vendor.qti.ims.rcsconfig@2.0.so vendor/lib/vendor.qti.ims.rcsconfig@2.1.so vendor/lib/vendor.qti.imsrtpservice@3.0-service-Impl.so -vendor/lib/vendor.qti.imsrtpservice@3.0.so;MODULE_SUFFIX=-vendor +vendor/lib/vendor.qti.imsrtpservice@3.0.so;MODULE_SUFFIX=_vendor vendor/lib/vendor.qti.latency@2.0.so vendor/lib/vendor.qti.latency@2.1.so vendor/lib/vendor.qti.latency@2.2.so @@ -1618,7 +1618,7 @@ vendor/lib64/vendor.qti.hardware.soter@1.0.so vendor/lib64/vendor.qti.hardware.trustedui@1.0.so vendor/lib64/vendor.qti.hardware.trustedui@1.1.so vendor/lib64/vendor.qti.hardware.trustedui@1.2.so -vendor/lib64/vendor.qti.hardware.tui_comm@1.0.so;MODULE_SUFFIX=-vendor +vendor/lib64/vendor.qti.hardware.tui_comm@1.0.so;MODULE_SUFFIX=_vendor vendor/lib64/vendor.qti.hardware.vpp@1.1.so vendor/lib64/vendor.qti.hardware.vpp@1.2.so vendor/lib64/vendor.qti.hardware.wifidisplaysession@1.0.so @@ -1632,7 +1632,7 @@ vendor/lib64/vendor.qti.ims.rcsconfig@1.1.so vendor/lib64/vendor.qti.ims.rcsconfig@2.0.so vendor/lib64/vendor.qti.ims.rcsconfig@2.1.so vendor/lib64/vendor.qti.imsrtpservice@3.0-service-Impl.so -vendor/lib64/vendor.qti.imsrtpservice@3.0.so;MODULE_SUFFIX=-vendor +vendor/lib64/vendor.qti.imsrtpservice@3.0.so;MODULE_SUFFIX=_vendor vendor/lib64/vendor.qti.latency@2.0.so vendor/lib64/vendor.qti.latency@2.1.so vendor/lib64/vendor.qti.latency@2.2.so diff --git a/proprietary-files.txt b/bramble/proprietary-files.txt similarity index 100% rename from proprietary-files.txt rename to bramble/proprietary-files.txt diff --git a/proprietary-firmware.txt b/bramble/proprietary-firmware.txt similarity index 100% rename from proprietary-firmware.txt rename to bramble/proprietary-firmware.txt diff --git a/bramble/setup-makefiles.py b/bramble/setup-makefiles.py new file mode 100755 index 0000000..32947cf --- /dev/null +++ b/bramble/setup-makefiles.py @@ -0,0 +1 @@ +#!./extract-files.py --regenerate_makefiles diff --git a/extract-files.py b/extract-files.py new file mode 100755 index 0000000..b9486e5 --- /dev/null +++ b/extract-files.py @@ -0,0 +1,13 @@ +#!/bin/bash +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +MY_DIR="$(cd "$(dirname "${0}")"; pwd -P)" + +pushd "${MY_DIR}/bramble" +./extract-files.py $@ +popd diff --git a/extract-files.sh b/extract-files.sh deleted file mode 100755 index 01251ce..0000000 --- a/extract-files.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -DEVICE=bramble -VENDOR=google - -# Load extract_utils and do some sanity checks -MY_DIR="${BASH_SOURCE%/*}" -if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi - -ANDROID_ROOT="${MY_DIR}/../../.." - -export TARGET_ENABLE_CHECKELF=true - -# If XML files don't have comments before the XML header, use this flag -# Can still be used with broken XML files by using blob_fixup -export TARGET_DISABLE_XML_FIXING=true - -HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" -if [ ! -f "${HELPER}" ]; then - echo "Unable to find helper script at ${HELPER}" - exit 1 -fi -source "${HELPER}" - -# Default to sanitizing the vendor folder before extraction -CLEAN_VENDOR=true - -ONLY_FIRMWARE= -KANG= -SECTION= - -while [ "${#}" -gt 0 ]; do - case "${1}" in - --only-firmware) - ONLY_FIRMWARE=true - ;; - -n | --no-cleanup) - CLEAN_VENDOR=false - ;; - -k | --kang) - KANG="--kang" - ;; - -s | --section) - SECTION="${2}" - shift - CLEAN_VENDOR=false - ;; - *) - SRC="${1}" - ;; - esac - shift -done - -if [ -z "${SRC}" ]; then - SRC="adb" -fi - -function blob_fixup() { - case "${1}" in - product/etc/felica/common.cfg) - [ "$2" = "" ] && return 0 - sed -i -e '$a00000018,1' -e '/^00000014/d' -e '/^00000015/d' "${2}" - ;; - # Fix typo in qcrilmsgtunnel whitelist - product/etc/sysconfig/nexus.xml) - [ "$2" = "" ] && return 0 - sed -i 's/qulacomm/qualcomm/' "${2}" - ;; - system_ext/priv-app/HbmSVManager/HbmSVManager.apk) - [ "$2" = "" ] && return 0 - apktool_patch "${2}" "${MY_DIR}/blob-patches/HbmSVManager.patch" -r - ;; - vendor/bin/hw/android.hardware.rebootescrow-service.citadel | \ - vendor/lib64/android.hardware.keymaster@4.1-impl.nos.so) - [ "$2" = "" ] && return 0 - "${PATCHELF}" --add-needed "libcrypto_shim.so" "${2}" - ;; - vendor/lib64/libgooglecamerahal.so) - [ "$2" = "" ] && return 0 - "${PATCHELF}" --add-needed "libmeminfo_shim.so" "${2}" - ;; - *) - return 1 - ;; - esac - - return 0 -} - -function blob_fixup_dry() { - blob_fixup "$1" "" -} - -function prepare_firmware() { - if [ "${SRC}" != "adb" ]; then - bash "${ANDROID_ROOT}"/lineage/scripts/pixel/prepare-firmware.sh "${DEVICE}" "${SRC}" - fi -} - -# Initialize the helper -setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" - -if [ -z "${ONLY_FIRMWARE}" ]; then - extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" - extract "${MY_DIR}/proprietary-files-carriersettings.txt" "${SRC}" "${KANG}" --section "${SECTION}" - extract "${MY_DIR}/proprietary-files-vendor.txt" "${SRC}" "${KANG}" --section "${SECTION}" -fi - -if [ -z "${SECTION}" ]; then - extract_firmware "${MY_DIR}/proprietary-firmware.txt" "${SRC}" -fi - -"${MY_DIR}/setup-makefiles.sh" diff --git a/setup-makefiles.py b/setup-makefiles.py new file mode 100755 index 0000000..a28b7ec --- /dev/null +++ b/setup-makefiles.py @@ -0,0 +1,13 @@ +#!/bin/bash +# +# SPDX-FileCopyrightText: 2024 The LineageOS Project +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +MY_DIR="$(cd "$(dirname "${0}")"; pwd -P)" + +pushd "${MY_DIR}/bramble" +./setup-makefiles.py +popd diff --git a/setup-makefiles.sh b/setup-makefiles.sh deleted file mode 100755 index d6a1e1a..0000000 --- a/setup-makefiles.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# -# SPDX-FileCopyrightText: 2016 The CyanogenMod Project -# SPDX-FileCopyrightText: 2017-2024 The LineageOS Project -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -DEVICE=bramble -VENDOR=google - -# Load extract_utils and do some sanity checks -MY_DIR="${BASH_SOURCE%/*}" -if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi - -ANDROID_ROOT="${MY_DIR}/../../.." - -export TARGET_ENABLE_CHECKELF=true - -HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" -if [ ! -f "${HELPER}" ]; then - echo "Unable to find helper script at ${HELPER}" - exit 1 -fi -source "${HELPER}" - -function vendor_imports() { - cat <>"$1" - "device/google/bramble", - "hardware/google/interfaces", - "hardware/google/pixel", - "hardware/qcom/sm7250/display", - "hardware/qcom/sm7250/gps", - "hardware/qcom/wlan/legacy", - "vendor/qcom/opensource/display" -EOF -} - -function lib_to_package_fixup_vendor_variants() { - if [ "$2" != "vendor" ]; then - return 1 - fi - - case "$1" in - vendor.qti.hardware.tui_comm@1.0 | \ - vendor.qti.imsrtpservice@3.0) - echo "$1-vendor" - ;; - libprotobuf-cpp-lite-21.12) - echo "libprotobuf-cpp-lite" - ;; - libwpa_client) ;; - *) - return 1 - ;; - esac -} - -function lib_to_package_fixup() { - lib_to_package_fixup_clang_rt_ubsan_standalone "$1" || - lib_to_package_fixup_proto_3_9_1 "$1" || - lib_to_package_fixup_vendor_variants "$@" -} - -# Initialize the helper -setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" - -# Warning headers and guards -write_headers - -write_makefiles "${MY_DIR}/proprietary-files.txt" -write_makefiles "${MY_DIR}/proprietary-files-carriersettings.txt" -write_makefiles "${MY_DIR}/proprietary-files-vendor.txt" - -append_firmware_calls_to_makefiles "${MY_DIR}/proprietary-firmware.txt" - -# Finish -write_footers