From 37c77b69d6cc3cec79261dfb04a588ab46aba4be Mon Sep 17 00:00:00 2001
From: David Arsene <80218600+DavidArsene@users.noreply.github.com>
Date: Thu, 28 Sep 2023 19:42:13 +0200
Subject: [PATCH 1/2] enhancer: add camera bootloader lock restriction fix

---
 enhancer/customize.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/enhancer/customize.sh b/enhancer/customize.sh
index d9b88ff..ab9e919 100755
--- a/enhancer/customize.sh
+++ b/enhancer/customize.sh
@@ -101,6 +101,20 @@ if $BOOTMODE; then
     touch "$MODPATH/system/lib64/libhal.wsm.samsung.so"
   fi
 
+  if [ -f "/vendor/lib/hw/camera.qcom.so" ]; then
+    if grep -q 'ro.boot.flash.locked' /vendor/lib/hw/camera.qcom.so; then
+      ui_print "I: Applying camera fix..."
+      mkdir -p "$MODPATH/system/vendor/lib/hw"
+      sed 's/ro.boot.flash.locked/ro.camera.notify_nfc/g' "/vendor/lib/hw/camera.qcom.so" > "$MODPATH/system/vendor/lib/hw/camera.qcom.so"
+      [ -f "/vendor/lib/hw/com.qti.chi.override.so" ] && sed 's/ro.boot.flash.locked/ro.camera.notify_nfc/g' "/vendor/lib/hw/com.qti.chi.override.so" > "$MODPATH/system/vendor/lib/hw/com.qti.chi.override.so"
+      if $IS64BIT; then
+        mkdir -p "$MODPATH/system/vendor/lib64/hw"
+        sed 's/ro.boot.flash.locked/ro.camera.notify_nfc/g' "/vendor/lib64/hw/camera.qcom.so" > "$MODPATH/system/vendor/lib64/hw/camera.qcom.so"
+        [ -f "/vendor/lib64/hw/com.qti.chi.override.so" ] && sed 's/ro.boot.flash.locked/ro.camera.notify_nfc/g' "/vendor/lib64/hw/com.qti.chi.override.so" > "$MODPATH/system/vendor/lib64/hw/com.qti.chi.override.so"
+      fi
+    fi
+  fi
+
   set_perm_recursive "$MODPATH" 0 0 0755 0644
 else
   ui_print "- Installing from recovery"

From 77bcca884b00ad86fe28521f5976e4c967e9284d Mon Sep 17 00:00:00 2001
From: BlackMesa123 <giangrecosalvo9@gmail.com>
Date: Fri, 29 Sep 2023 18:55:19 +0200
Subject: [PATCH 2/2] enhancer: fix file permission/context in boot mode

Signed-off-by: BlackMesa123 <giangrecosalvo9@gmail.com>
---
 enhancer/customize.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/enhancer/customize.sh b/enhancer/customize.sh
index ab9e919..79a2971 100755
--- a/enhancer/customize.sh
+++ b/enhancer/customize.sh
@@ -115,7 +115,21 @@ if $BOOTMODE; then
     fi
   fi
 
+  ui_print "I: Fixing file permissions..."
   set_perm_recursive "$MODPATH" 0 0 0755 0644
+  set_perm_recursive "$MODPATH/system/lib" 0 0 0755 0644 "u:object_r:system_lib_file:s0"
+  $IS64BIT && set_perm_recursive "$MODPATH/system/lib64" 0 0 0755 0644 "u:object_r:system_lib_file:s0"
+  if [ -e "$MODPATH/system/vendor" ]; then
+    set_perm_recursive "$MODPATH/system/vendor" 0 2000 0755 0644 "u:object_r:vendor_file:s0"
+    set_perm "$MODPATH/system/vendor/lib/hw" 0 2000 0755 "u:object_r:vendor_hal_file:s0"
+    set_perm "$MODPATH/system/vendor/lib/hw/camera.qcom.so" 0 0 0644 "u:object_r:vendor_file:s0"
+    [ -f "$MODPATH/system/vendor/lib/hw/com.qti.chi.override.so" ] && set_perm "$MODPATH/system/vendor/lib/hw/com.qti.chi.override.so" 0 0 0644 "u:object_r:vendor_file:s0"
+    if $IS64BIT; then
+      set_perm "$MODPATH/system/vendor/lib64/hw" 0 2000 0755 "u:object_r:vendor_hal_file:s0"
+      set_perm "$MODPATH/system/vendor/lib64/hw/camera.qcom.so" 0 0 0644 "u:object_r:vendor_file:s0"
+      [ -f "$MODPATH/system/vendor/lib64/hw/com.qti.chi.override.so" ] && set_perm "$MODPATH/system/vendor/lib64/hw/com.qti.chi.override.so" 0 0 0644 "u:object_r:vendor_file:s0"
+    fi
+  fi
 else
   ui_print "- Installing from recovery"