diff --git a/Android.bp b/Android.bp
index 9e493df..feb087a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,6 +1,6 @@
// Automatically generated file. DO NOT MODIFY
//
-// This file is generated by device/xiaomi/lisa-miuicamera/setup-makefiles.sh
+// This file is generated by vendor/xiaomi/camera/setup-makefiles.sh
soong_namespace {
}
diff --git a/Android.mk b/Android.mk
index a9e7e54..3abd1d8 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,9 +1,20 @@
# Automatically generated file. DO NOT MODIFY
#
-# This file is generated by device/xiaomi/lisa-miuicamera/setup-makefiles.sh
+# This file is generated by vendor/xiaomi/camera/setup-makefiles.sh
LOCAL_PATH := $(call my-dir)
-ifeq ($(TARGET_DEVICE),lisa-miuicamera)
+ifneq ($(filter lisa,$(TARGET_DEVICE)),)
+
+CAMERA_LIBRARIES := libcamera_algoup_jni.xiaomi.so libcamera_mianode_jni.xiaomi.so
+
+CAMERA_SYMLINKS := $(addprefix $(TARGET_OUT_APPS_PRIVILEGED)/MiuiCamera/lib/arm64/,$(notdir $(CAMERA_LIBRARIES)))
+$(CAMERA_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
+ @echo "MiuiCamera lib link: $@"
+ @mkdir -p $(dir $@)
+ @rm -rf $@
+ $(hide) ln -sf /system/lib64/$(notdir $@) $@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(CAMERA_SYMLINKS)
endif
diff --git a/BoardConfigVendor.mk b/BoardConfigVendor.mk
index 75f98f5..59d0ce1 100644
--- a/BoardConfigVendor.mk
+++ b/BoardConfigVendor.mk
@@ -1,4 +1,4 @@
# Automatically generated file. DO NOT MODIFY
#
-# This file is generated by device/xiaomi/lisa-miuicamera/setup-makefiles.sh
+# This file is generated by vendor/xiaomi/camera/setup-makefiles.sh
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0098a26
--- /dev/null
+++ b/README.md
@@ -0,0 +1,27 @@
+# proprietary_vendor_xiaomi_camera
+
+Prebuilt stock MIUI Camera to include in custom ROM builds.
+
+Extracted from lisa MIUI package (refer proprietary-files.txt for version).
+
+### Supported devices
+* Xiaomi 11 Lite NE (lisa)
+
+### How to use?
+
+1. Clone this repo to `vendor/xiaomi/camera`
+
+2. Inherit it from `device.mk` in device tree:
+
+```
+# Camera
+$(call inherit-product-if-exists, vendor/xiaomi/camera/miuicamera.mk)
+```
+
+3. Set `ro.product.mod_device` according to stock, and `ro.miui.notch=1` if the device has a display cutout, for example:
+
+```
+PRODUCT_SYSTEM_PROPERTIES += \
+ ro.miui.notch=1 \
+ ro.product.mod_device=lisa
+```
diff --git a/camera-vendor.mk b/camera-vendor.mk
new file mode 100644
index 0000000..d1839f6
--- /dev/null
+++ b/camera-vendor.mk
@@ -0,0 +1,16 @@
+# Automatically generated file. DO NOT MODIFY
+#
+# This file is generated by vendor/xiaomi/camera/setup-makefiles.sh
+
+PRODUCT_SOONG_NAMESPACES += \
+ vendor/xiaomi/camera
+
+PRODUCT_COPY_FILES += \
+ vendor/xiaomi/camera/proprietary/system/lib64/libcamera_algoup_jni.xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libcamera_algoup_jni.xiaomi.so \
+ vendor/xiaomi/camera/proprietary/system/lib64/libcamera_mianode_jni.xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libcamera_mianode_jni.xiaomi.so \
+ vendor/xiaomi/camera/proprietary/system/lib64/libgui-xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libgui-xiaomi.so \
+ vendor/xiaomi/camera/proprietary/system/lib64/libmicampostproc_client.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libmicampostproc_client.so \
+ vendor/xiaomi/camera/proprietary/system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/vendor.xiaomi.hardware.campostproc@1.0.so
+
+PRODUCT_PACKAGES += \
+ MiuiCamera
diff --git a/configs/permissions/default-permissions-miuicamera.xml b/configs/permissions/default-permissions-miuicamera.xml
new file mode 100644
index 0000000..fa09489
--- /dev/null
+++ b/configs/permissions/default-permissions-miuicamera.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/configs/permissions/miuicamera-hiddenapi-package-whitelist.xml b/configs/permissions/miuicamera-hiddenapi-package-whitelist.xml
new file mode 100644
index 0000000..aa1df44
--- /dev/null
+++ b/configs/permissions/miuicamera-hiddenapi-package-whitelist.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/configs/permissions/privapp-permissions-miuicamera.xml b/configs/permissions/privapp-permissions-miuicamera.xml
new file mode 100644
index 0000000..eaf600b
--- /dev/null
+++ b/configs/permissions/privapp-permissions-miuicamera.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extract-files.sh b/extract-files.sh
new file mode 100755
index 0000000..c59762d
--- /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=camera
+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/libgui-xiaomi.so)
+ patchelf --set-soname libgui-xiaomi.so "${2}"
+ ;;
+ system/lib64/libcamera_algoup_jni.xiaomi.so|system/lib64/libcamera_mianode_jni.xiaomi.so)
+ patchelf --replace-needed libgui.so libgui-xiaomi.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/lisa-miuicamera-vendor.mk b/lisa-miuicamera-vendor.mk
deleted file mode 100644
index 835ddee..0000000
--- a/lisa-miuicamera-vendor.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Automatically generated file. DO NOT MODIFY
-#
-# This file is generated by device/xiaomi/lisa-miuicamera/setup-makefiles.sh
-
-PRODUCT_SOONG_NAMESPACES += \
- vendor/xiaomi/lisa-miuicamera
-
-PRODUCT_COPY_FILES += \
- vendor/xiaomi/lisa-miuicamera/proprietary/system/lib64/libcamera_algoup_jni.xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libcamera_algoup_jni.xiaomi.so \
- vendor/xiaomi/lisa-miuicamera/proprietary/system/lib64/libcamera_mianode_jni.xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libcamera_mianode_jni.xiaomi.so \
- vendor/xiaomi/lisa-miuicamera/proprietary/system/lib64/libgui-xiaomi.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libgui-xiaomi.so \
- vendor/xiaomi/lisa-miuicamera/proprietary/system/lib64/libmicampostproc_client.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libmicampostproc_client.so \
- vendor/xiaomi/lisa-miuicamera/proprietary/system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/vendor.xiaomi.hardware.campostproc@1.0.so
-
-PRODUCT_PACKAGES += \
- MiuiCamera
diff --git a/miuicamera.mk b/miuicamera.mk
new file mode 100644
index 0000000..310fac6
--- /dev/null
+++ b/miuicamera.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2023 Paranoid Android
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+# Permissions
+PRODUCT_COPY_FILES += \
+ vendor/xiaomi/camera/configs/permissions/default-permissions-miuicamera.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/default-permissions/default-permissions-miuicamera.xml \
+ vendor/xiaomi/camera/configs/permissions/miuicamera-hiddenapi-package-whitelist.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/sysconfig/miuicamera-hiddenapi-package-whitelist.xml \
+ vendor/xiaomi/camera/configs/permissions/privapp-permissions-miuicamera.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/privapp-permissions-miuicamera.xml
+
+# Properties
+PRODUCT_SYSTEM_PROPERTIES += \
+ persist.vendor.camera.privapp.list=org.codeaurora.snapcam,com.android.camera \
+ ro.com.google.lens.oem_camera_package=com.android.camera \
+ vendor.camera.aux.packagelist=org.codeaurora.snapcam,com.android.camera
+
+# Sepolicy
+BOARD_VENDOR_SEPOLICY_DIRS += \
+ vendor/xiaomi/camera/sepolicy/vendor
+
+$(call inherit-product, vendor/xiaomi/camera/camera-vendor.mk)
diff --git a/proprietary-files.txt b/proprietary-files.txt
new file mode 100644
index 0000000..cf73a51
--- /dev/null
+++ b/proprietary-files.txt
@@ -0,0 +1,7 @@
+# From lisa MIUI V14.0.3.0.TKOMIXM package
+-product/priv-app/MiuiCamera/MiuiCamera.apk:system/priv-app/MiuiCamera/MiuiCamera.apk;OVERRIDES=Camera,Camera2,GoogleCameraGo
+system/lib64/libcamera_algoup_jni.xiaomi.so
+system/lib64/libcamera_mianode_jni.xiaomi.so
+system/lib64/libgui.so:system/lib64/libgui-xiaomi.so
+system/lib64/libmicampostproc_client.so
+system/lib64/vendor.xiaomi.hardware.campostproc@1.0.so
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
new file mode 100644
index 0000000..8b7b95f
--- /dev/null
+++ b/sepolicy/vendor/file_contexts
@@ -0,0 +1,8 @@
+/vendor/lib(64)?/libSNPE\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libc\+\+_shared\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libhta\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libsnpe_dsp_domains_v2\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libsnpe_dsp_domains_v3\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/rfsa/adsp/libsnpe_htp_v65_skel\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/rfsa/adsp/libsnpe_htp_v66_skel\.so u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/rfsa/adsp/libsnpe_htp_v68_skel\.so u:object_r:same_process_hal_file:s0
diff --git a/sepolicy/vendor/hal_camera_default.te b/sepolicy/vendor/hal_camera_default.te
new file mode 100644
index 0000000..a112595
--- /dev/null
+++ b/sepolicy/vendor/hal_camera_default.te
@@ -0,0 +1 @@
+binder_call(hal_camera_default, platform_app)
diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te
new file mode 100644
index 0000000..eb1ccf8
--- /dev/null
+++ b/sepolicy/vendor/platform_app.te
@@ -0,0 +1,7 @@
+allow platform_app app_data_file:file execute;
+allow platform_app hal_xiaomi_camera_hwservice:hwservice_manager find;
+
+binder_call(platform_app, hal_camera_default)
+
+get_prop(platform_app, vendor_camera_prop)
+get_prop(platform_app, vendor_fp_prop)
diff --git a/setup-makefiles.sh b/setup-makefiles.sh
new file mode 100755
index 0000000..dbc34e6
--- /dev/null
+++ b/setup-makefiles.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Copyright (C) 2016 The CyanogenMod Project
+# Copyright (C) 2017-2020 The LineageOS Project
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+set -e
+
+DEVICE=camera
+DEVICE_COMMON=camera
+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}" true
+
+# Warning headers and guards
+write_headers "lisa"
+sed -i 's|device/|vendor/|g' "$ANDROIDBP" "$ANDROIDMK" "$BOARDMK" "$PRODUCTMK"
+
+cat << 'EOF' >> "$ANDROIDMK"
+CAMERA_LIBRARIES := libcamera_algoup_jni.xiaomi.so libcamera_mianode_jni.xiaomi.so
+
+CAMERA_SYMLINKS := $(addprefix $(TARGET_OUT_APPS_PRIVILEGED)/MiuiCamera/lib/arm64/,$(notdir $(CAMERA_LIBRARIES)))
+$(CAMERA_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
+ @echo "MiuiCamera lib link: $@"
+ @mkdir -p $(dir $@)
+ @rm -rf $@
+ $(hide) ln -sf /system/lib64/$(notdir $@) $@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(CAMERA_SYMLINKS)
+
+EOF
+
+write_makefiles "${MY_DIR}/proprietary-files.txt" true
+
+# Finish
+write_footers