From 8559d0e59984ef4e4bf1c75ea1acdfc0111c3e0a Mon Sep 17 00:00:00 2001 From: Arian Date: Sun, 9 Jul 2023 23:17:33 +0200 Subject: [PATCH] Initial MiuiCamera for zeus --- .gitignore | 1 + BoardConfig.mk | 16 +++++ ...miuicamera-hiddenapi-package-allowlist.xml | 4 ++ configs/privapp-permissions-miuicamera.xml | 13 ++++ device.mk | 20 ++++++ extract-files.sh | 72 +++++++++++++++++++ proprietary-files.txt | 8 +++ sepolicy/vendor/platform_app.te | 18 +++++ setup-makefiles.sh | 36 ++++++++++ shims/Android.bp | 10 +++ shims/libgui_shim_miuicamera.c | 9 +++ system.prop | 9 +++ 12 files changed, 216 insertions(+) create mode 100644 .gitignore create mode 100644 BoardConfig.mk create mode 100644 configs/miuicamera-hiddenapi-package-allowlist.xml create mode 100644 configs/privapp-permissions-miuicamera.xml create mode 100644 device.mk create mode 100755 extract-files.sh create mode 100644 proprietary-files.txt create mode 100644 sepolicy/vendor/platform_app.te create mode 100755 setup-makefiles.sh create mode 100644 shims/Android.bp create mode 100644 shims/libgui_shim_miuicamera.c create mode 100644 system.prop diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2e7d76 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +MiuiCamera/ diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..f6aa8be --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,16 @@ +# +# Copyright (C) 2023 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Inherit from the proprietary version +include vendor/xiaomi/miuicamera-zeus/BoardConfigVendor.mk + +MIUICAMERA_PATH := device/xiaomi/miuicamera-zeus + +# Properties +TARGET_SYSTEM_PROP += $(MIUICAMERA_PATH)/system.prop + +# Sepolicy +BOARD_VENDOR_SEPOLICY_DIRS += $(MIUICAMERA_PATH)/sepolicy/vendor diff --git a/configs/miuicamera-hiddenapi-package-allowlist.xml b/configs/miuicamera-hiddenapi-package-allowlist.xml new file mode 100644 index 0000000..b8ed90d --- /dev/null +++ b/configs/miuicamera-hiddenapi-package-allowlist.xml @@ -0,0 +1,4 @@ + + + + diff --git a/configs/privapp-permissions-miuicamera.xml b/configs/privapp-permissions-miuicamera.xml new file mode 100644 index 0000000..bbff34f --- /dev/null +++ b/configs/privapp-permissions-miuicamera.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/device.mk b/device.mk new file mode 100644 index 0000000..8ea56b7 --- /dev/null +++ b/device.mk @@ -0,0 +1,20 @@ +# +# Copyright (C) 2023 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Inherit from the proprietary version +$(call inherit-product, vendor/xiaomi/miuicamera-zeus/miuicamera-zeus-vendor.mk) + +# Priv-app permission +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/privapp-permissions-miuicamera.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/privapp-permissions-miuicamera.xml + +# Shims +PRODUCT_PACKAGES += \ + libgui_shim_miuicamera + +# Sysconfig +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/miuicamera-hiddenapi-package-allowlist.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/sysconfig/miuicamera-hiddenapi-package-allowlist.xml diff --git a/extract-files.sh b/extract-files.sh new file mode 100755 index 0000000..757854d --- /dev/null +++ b/extract-files.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Copyright (C) 2016 The CyanogenMod Project +# Copyright (C) 2017-2020 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +DEVICE=miuicamera-zeus +VENDOR=xiaomi + +# 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}/../../.." + +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 + +KANG= +SECTION= + +while [ "${#}" -gt 0 ]; do + case "${1}" in + -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 + system/lib64/libcamera_algoup_jni.xiaomi.so|system/lib64/libcamera_mianode_jni.xiaomi.so) + "${PATCHELF}" --add-needed "libgui_shim_miuicamera.so" "${2}" + ;; + system/lib64/libmicampostproc_client.so) + "${PATCHELF}" --remove-needed "libhidltransport.so" "${2}" + ;; + esac +} + +# Initialize the helper +setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" + +extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" + +"${MY_DIR}/setup-makefiles.sh" diff --git a/proprietary-files.txt b/proprietary-files.txt new file mode 100644 index 0000000..10b638b --- /dev/null +++ b/proprietary-files.txt @@ -0,0 +1,8 @@ +# All unpinned blobs below are extracted from zeus V14.0.7.0.TLBMIXM + +product/priv-app/MiuiCamera/MiuiCamera.apk:system/priv-app/MiuiCamera/MiuiCamera.apk|962075aefbc57006f05aabf79cfdfc96e5bf0682 +system/etc/public.libraries-xiaomi.txt +system/lib64/libcamera_algoup_jni.xiaomi.so +system/lib64/libcamera_mianode_jni.xiaomi.so +system/lib64/libmicampostproc_client.so +system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te new file mode 100644 index 0000000..e7ea164 --- /dev/null +++ b/sepolicy/vendor/platform_app.te @@ -0,0 +1,18 @@ +hal_client_domain(platform_app, vendor_hal_camerapostproc_xiaomi) + +binder_use(platform_app) +binder_call(platform_app, vendor_hal_camerapostproc_xiaomi) +allow platform_app vendor_hal_camerapostproc_xiaomi_hwservice:hwservice_manager find; + +allow platform_app adsprpcd_file:dir { open read search }; +allow platform_app vendor_xdsp_device:chr_file { ioctl open read write }; +allow platform_app vendor_qdsp_device:chr_file { ioctl open read write }; + +allow platform_app vendor_camera_data_file:dir { append map r_dir_perms write }; +allow platform_app vendor_camera_data_file:file { getattr open read }; + +# Properties +allow platform_app vendor_display_prop:file read; +get_prop(platform_app, vendor_camera_sensor_prop) +get_prop(platform_app, vendor_displayfeature_prop) +get_prop(platform_app, vendor_panel_info_prop) diff --git a/setup-makefiles.sh b/setup-makefiles.sh new file mode 100755 index 0000000..5eb45fe --- /dev/null +++ b/setup-makefiles.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright (C) 2016 The CyanogenMod Project +# Copyright (C) 2017-2020 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +DEVICE=miuicamera-zeus +VENDOR=xiaomi + +# 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}/../../.." + +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}" + +# Initialize the helper +setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" + +# Warning headers and guards +write_headers + +write_makefiles "${MY_DIR}/proprietary-files.txt" true + +# Finish +write_footers diff --git a/shims/Android.bp b/shims/Android.bp new file mode 100644 index 0000000..1cf1a7a --- /dev/null +++ b/shims/Android.bp @@ -0,0 +1,10 @@ +// +// Copyright (C) 2022 The LineageOS Project +// +// SPDX-License-Identifier: Apache-2.0 +// + +cc_library { + name: "libgui_shim_miuicamera", + srcs: ["libgui_shim_miuicamera.c"], +} diff --git a/shims/libgui_shim_miuicamera.c b/shims/libgui_shim_miuicamera.c new file mode 100644 index 0000000..53adfd1 --- /dev/null +++ b/shims/libgui_shim_miuicamera.c @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2023 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +void _ZN7android18BnProducerListener16onBufferDetachedEi() { + return; +} diff --git a/system.prop b/system.prop new file mode 100644 index 0000000..dedd5a0 --- /dev/null +++ b/system.prop @@ -0,0 +1,9 @@ +# Google Lens +ro.com.google.lens.oem_camera_package=com.android.camera + +# Framework allowlists +persist.vendor.camera.privapp.list=com.android.camera +#vendor.camera.aux.packagelist=com.android.camera + +# MiuiCamera +ro.miui.notch=1