diff --git a/BoardConfigMiuiCamera.mk b/BoardConfigMiuiCamera.mk
index 76da036..b21f632 100644
--- a/BoardConfigMiuiCamera.mk
+++ b/BoardConfigMiuiCamera.mk
@@ -18,4 +18,6 @@ BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true
TARGET_SYSTEM_PROP += $(MIUICAMERA_PATH)/system.prop
# Sepolicy
+SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += $(MIUICAMERA_PATH)/sepolicy/private
+SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += $(MIUICAMERA_PATH)/sepolicy/public
BOARD_VENDOR_SEPOLICY_DIRS += $(MIUICAMERA_PATH)/sepolicy/vendor
diff --git a/MiuiCamera.mk b/MiuiCamera.mk
index 1501ffe..eb93eb9 100644
--- a/MiuiCamera.mk
+++ b/MiuiCamera.mk
@@ -7,6 +7,13 @@
# Inherit from the proprietary version
$(call inherit-product, vendor/xiaomi/miuicamera/common/common-vendor.mk)
+# HIDL
+PRODUCT_PACKAGES += \
+ android.hidl.base@1.0 \
+ android.hidl.base@1.0.vendor \
+ android.hidl.memory.block@1.0 \
+ android.hidl.memory.block@1.0.vendor
+
# Priv-app permission
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/configs/privapp-permissions-miui.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/privapp-permissions-miui.xml
diff --git a/common/Android.bp b/common/Android.bp
index 513872e..0d1a1b9 100644
--- a/common/Android.bp
+++ b/common/Android.bp
@@ -30,6 +30,33 @@ android_app_import {
privileged: true,
}
+prebuilt_etc_xml {
+ name: "vendor.xiaomi.hardware.misys@1.0",
+ owner: "xiaomi/miuicamera",
+ src: "proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@1.0.xml",
+ filename_from_src: true,
+ sub_dir: "vintf/manifest",
+ soc_specific: true,
+}
+
+prebuilt_etc_xml {
+ name: "vendor.xiaomi.hardware.misys@2.0",
+ owner: "xiaomi/miuicamera",
+ src: "proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@2.0.xml",
+ filename_from_src: true,
+ sub_dir: "vintf/manifest",
+ soc_specific: true,
+}
+
+prebuilt_etc_xml {
+ name: "vendor.xiaomi.hardware.misys@3.0",
+ owner: "xiaomi/miuicamera",
+ src: "proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@3.0.xml",
+ filename_from_src: true,
+ sub_dir: "vintf/manifest",
+ soc_specific: true,
+}
+
install_symlink {
name: "libcamera_algoup_jni.xiaomi_libcamera_algoup_jni.xiaomi_symlink64",
installed_location: "system/priv-app/MiuiCamera/lib/arm64/libcamera_algoup_jni.xiaomi.so",
diff --git a/common/common-vendor.mk b/common/common-vendor.mk
index 22f6dc4..a0293a2 100644
--- a/common/common-vendor.mk
+++ b/common/common-vendor.mk
@@ -17,11 +17,28 @@ PRODUCT_COPY_FILES += \
vendor/xiaomi/miuicamera/common/proprietary/system/lib64/libgallery_mpbase.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libgallery_mpbase.so \
vendor/xiaomi/miuicamera/common/proprietary/system/lib64/libmibokeh_gallery.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/libmibokeh_gallery.so \
vendor/xiaomi/miuicamera/common/proprietary/system/lib64/librefocus.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/librefocus.so \
- vendor/xiaomi/miuicamera/common/proprietary/system/lib64/librefocus_mibokeh.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/librefocus_mibokeh.so
+ vendor/xiaomi/miuicamera/common/proprietary/system/lib64/librefocus_mibokeh.so:$(TARGET_COPY_OUT_SYSTEM)/lib64/librefocus_mibokeh.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service:$(TARGET_COPY_OUT_VENDOR)/bin/hw/vendor.xiaomi.hardware.misys@1.0-service \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service:$(TARGET_COPY_OUT_VENDOR)/bin/hw/vendor.xiaomi.hardware.misys@2.0-service \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service:$(TARGET_COPY_OUT_VENDOR)/bin/hw/vendor.xiaomi.hardware.misys@3.0-service \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so:$(TARGET_COPY_OUT_VENDOR)/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so:$(TARGET_COPY_OUT_VENDOR)/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so:$(TARGET_COPY_OUT_VENDOR)/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/libcheckpid.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libcheckpid.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/liblogwrap_vendor.so:$(TARGET_COPY_OUT_VENDOR)/lib64/liblogwrap_vendor.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@1.0.so:$(TARGET_COPY_OUT_VENDOR)/lib64/vendor.xiaomi.hardware.misys@1.0.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@2.0.so:$(TARGET_COPY_OUT_VENDOR)/lib64/vendor.xiaomi.hardware.misys@2.0.so \
+ vendor/xiaomi/miuicamera/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@3.0.so:$(TARGET_COPY_OUT_VENDOR)/lib64/vendor.xiaomi.hardware.misys@3.0.so
PRODUCT_PACKAGES += \
MiuiCamera \
- MiuiExtraPhoto
+ MiuiExtraPhoto \
+ vendor.xiaomi.hardware.misys@1.0 \
+ vendor.xiaomi.hardware.misys@2.0 \
+ vendor.xiaomi.hardware.misys@3.0
PRODUCT_PACKAGES += \
libcamera_algoup_jni.xiaomi_libcamera_algoup_jni.xiaomi_symlink64 \
diff --git a/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service
new file mode 100644
index 0000000..c60e86e
Binary files /dev/null and b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service differ
diff --git a/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service
new file mode 100644
index 0000000..e9d62a6
Binary files /dev/null and b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service differ
diff --git a/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service
new file mode 100644
index 0000000..645bbed
Binary files /dev/null and b/common/proprietary/vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service differ
diff --git a/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc
new file mode 100644
index 0000000..aabd6dc
--- /dev/null
+++ b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc
@@ -0,0 +1,8 @@
+on fs
+ mkdir /mnt/vendor/persist/stability 0755 system system
+ mkdir /mnt/vendor/persist/misys 0755 system system
+
+service vendor.misys /vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service
+ class hal
+ user system
+ group system root
diff --git a/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc
new file mode 100644
index 0000000..504bd0f
--- /dev/null
+++ b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc
@@ -0,0 +1,8 @@
+on fs
+ mkdir /mnt/vendor/persist/stability 0755 system system
+ mkdir /mnt/vendor/persist/misys 0755 system system
+
+service vendor.misys@2.0 /vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service
+ class hal
+ user system
+ group system
diff --git a/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc
new file mode 100644
index 0000000..906ddda
--- /dev/null
+++ b/common/proprietary/vendor/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc
@@ -0,0 +1,8 @@
+on fs
+ mkdir /mnt/vendor/persist/stability 0755 system system
+ mkdir /mnt/vendor/persist/misys 0755 system system
+
+service vendor.misys@3.0 /vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service
+ class hal
+ user system
+ group system
diff --git a/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@1.0.xml b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@1.0.xml
new file mode 100644
index 0000000..1510521
--- /dev/null
+++ b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@1.0.xml
@@ -0,0 +1,38 @@
+
+
+
+ vendor.xiaomi.hardware.misys
+ hwbinder
+ 1.0
+
+ IMiSys
+ default
+
+
+
diff --git a/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@2.0.xml b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@2.0.xml
new file mode 100644
index 0000000..2e148db
--- /dev/null
+++ b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@2.0.xml
@@ -0,0 +1,38 @@
+
+
+
+ vendor.xiaomi.hardware.misys
+ hwbinder
+ 2.0
+
+ IMiSys
+ default
+
+
+
diff --git a/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@3.0.xml b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@3.0.xml
new file mode 100644
index 0000000..df402fe
--- /dev/null
+++ b/common/proprietary/vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@3.0.xml
@@ -0,0 +1,38 @@
+
+
+
+ vendor.xiaomi.hardware.misys
+ hwbinder
+ 3.0
+
+ IMiSys
+ default
+
+
+
diff --git a/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so
new file mode 100644
index 0000000..6da16f9
Binary files /dev/null and b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so differ
diff --git a/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so
new file mode 100644
index 0000000..e98c0e1
Binary files /dev/null and b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so differ
diff --git a/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so
new file mode 100644
index 0000000..5730d69
Binary files /dev/null and b/common/proprietary/vendor/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so differ
diff --git a/common/proprietary/vendor/lib64/libcheckpid.so b/common/proprietary/vendor/lib64/libcheckpid.so
new file mode 100644
index 0000000..eb5093f
Binary files /dev/null and b/common/proprietary/vendor/lib64/libcheckpid.so differ
diff --git a/common/proprietary/vendor/lib64/liblogwrap_vendor.so b/common/proprietary/vendor/lib64/liblogwrap_vendor.so
new file mode 100644
index 0000000..9671b95
Binary files /dev/null and b/common/proprietary/vendor/lib64/liblogwrap_vendor.so differ
diff --git a/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@1.0.so b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@1.0.so
new file mode 100644
index 0000000..9a9620e
Binary files /dev/null and b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@1.0.so differ
diff --git a/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@2.0.so b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@2.0.so
new file mode 100644
index 0000000..0528d9c
Binary files /dev/null and b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@2.0.so differ
diff --git a/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@3.0.so b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@3.0.so
new file mode 100644
index 0000000..744b934
Binary files /dev/null and b/common/proprietary/vendor/lib64/vendor.xiaomi.hardware.misys@3.0.so differ
diff --git a/proprietary-files.txt b/proprietary-files.txt
index b010038..3c62aff 100644
--- a/proprietary-files.txt
+++ b/proprietary-files.txt
@@ -1,5 +1,24 @@
# All unpinned blobs below are extracted from V14.0.4.0.SJWMIXM (CURTANAGlobal)
+# MiSys
+vendor/bin/hw/vendor.xiaomi.hardware.misys@1.0-service
+vendor/bin/hw/vendor.xiaomi.hardware.misys@2.0-service
+vendor/bin/hw/vendor.xiaomi.hardware.misys@3.0-service
+vendor/etc/init/vendor.xiaomi.hardware.misys@1.0-service.rc
+vendor/etc/init/vendor.xiaomi.hardware.misys@2.0-service.rc
+vendor/etc/init/vendor.xiaomi.hardware.misys@3.0-service.rc
+vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@1.0.xml
+vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@2.0.xml
+vendor/etc/vintf/manifest/vendor.xiaomi.hardware.misys@3.0.xml
+vendor/lib64/hw/vendor.xiaomi.hardware.misys@1.0-impl.so
+vendor/lib64/hw/vendor.xiaomi.hardware.misys@2.0-impl.so
+vendor/lib64/hw/vendor.xiaomi.hardware.misys@3.0-impl.so
+vendor/lib64/libcheckpid.so
+vendor/lib64/liblogwrap_vendor.so
+vendor/lib64/vendor.xiaomi.hardware.misys@1.0.so
+vendor/lib64/vendor.xiaomi.hardware.misys@2.0.so
+vendor/lib64/vendor.xiaomi.hardware.misys@3.0.so
+
# MiuiCamera
system/lib64/libcamera_algoup_jni.xiaomi.so;SYMLINK=system/priv-app/MiuiCamera/lib/arm64/libcamera_algoup_jni.xiaomi.so
system/lib64/libcamera_mianode_jni.xiaomi.so;SYMLINK=system/priv-app/MiuiCamera/lib/arm64/libcamera_mianode_jni.xiaomi.so
diff --git a/sepolicy/private/platform_app.te b/sepolicy/private/platform_app.te
new file mode 100644
index 0000000..6ad7e7f
--- /dev/null
+++ b/sepolicy/private/platform_app.te
@@ -0,0 +1 @@
+hal_client_domain(platform_app, hal_misys)
diff --git a/sepolicy/private/priv_app.te b/sepolicy/private/priv_app.te
new file mode 100644
index 0000000..315f42d
--- /dev/null
+++ b/sepolicy/private/priv_app.te
@@ -0,0 +1 @@
+hal_client_domain(priv_app, hal_misys)
diff --git a/sepolicy/public/attributes b/sepolicy/public/attributes
new file mode 100644
index 0000000..e7f54f1
--- /dev/null
+++ b/sepolicy/public/attributes
@@ -0,0 +1 @@
+hal_attribute_lineage(misys)
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
new file mode 100644
index 0000000..9b72233
--- /dev/null
+++ b/sepolicy/vendor/file_contexts
@@ -0,0 +1,4 @@
+# Misys
+/(vendor|system/vendor)/bin/hw/vendor\.xiaomi\.hardware\.misys@1\.0-service u:object_r:hal_misys_default_exec:s0
+/(vendor|system/vendor)/bin/hw/vendor\.xiaomi\.hardware\.misys@2\.0-service u:object_r:hal_misys_default_exec:s0
+/(vendor|system/vendor)/bin/hw/vendor\.xiaomi\.hardware\.misys@3\.0-service u:object_r:hal_misys_default_exec:s0
diff --git a/sepolicy/vendor/hal_misys.te b/sepolicy/vendor/hal_misys.te
new file mode 100644
index 0000000..2072c83
--- /dev/null
+++ b/sepolicy/vendor/hal_misys.te
@@ -0,0 +1,5 @@
+# HwBinder IPC from client to server
+binder_call(hal_misys_client, hal_misys_server)
+
+add_hwservice(hal_misys_server, hal_misys_hwservice)
+allow hal_misys_client hal_misys_hwservice:hwservice_manager find;
diff --git a/sepolicy/vendor/hal_misys_default.te b/sepolicy/vendor/hal_misys_default.te
new file mode 100644
index 0000000..46be8d2
--- /dev/null
+++ b/sepolicy/vendor/hal_misys_default.te
@@ -0,0 +1,13 @@
+type hal_misys_default, domain;
+hal_server_domain(hal_misys_default, hal_misys)
+
+type hal_misys_default_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(hal_misys_default)
+
+allow hal_misys_default camera_persist_file:file rw_file_perms;
+allow hal_misys_default camera_persist_file:dir rw_dir_perms;
+r_dir_file(hal_misys_default, firmware_file)
+r_dir_file(hal_misys_default, mnt_vendor_file)
+
+get_prop(hal_misys_default, vendor_camera_prop)