Add a script to properly flash Hydrogen OS reserve.img
authormauronofrio <poronofrio@gmail.com>
Mon, 22 Jul 2019 11:18:17 +0000 (13:18 +0200)
committermauronofrio <poronofrio@gmail.com>
Mon, 22 Jul 2019 11:18:17 +0000 (13:18 +0200)
recovery/root/init.recovery.qcom.rc
recovery/root/sbin/patchreserve.sh [new file with mode: 0755]

index fd81196a4e4f9401d7175e480a4c12e4bf59d51c..89d15cc302bc1df9b38ab90426f65cdc3ce4588d 100644 (file)
@@ -37,11 +37,6 @@ on fs
     symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_a
     symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_b
 
-    # this is not good way for Hydrogen payload reserve
-    write  /dev/block/bootdevice/by-name/reserve 0
-    symlink /dev/block/bootdevice/by-name/reserve /dev/block/bootdevice/by-name/reserve_a
-    symlink /dev/block/bootdevice/by-name/reserve /dev/block/bootdevice/by-name/reserve_b
-
     chmod 0660 /dev/qseecom
     chown system drmrpc /dev/qseecom
     chmod 0664 /dev/ion
@@ -122,6 +117,13 @@ service time_daemon /sbin/time_daemon
     disabled
     seclabel u:r:recovery:s0
 
+service patchreserve /sbin/patchreserve.sh
+    user root
+    group root
+    disabled
+    oneshot
+    seclabel u:r:recovery:s0
+
 # This helps fix ld.config.txt errors from the linker on Android 8.1+
 service ldconfigtxt /sbin/touch /sbin/ld.config.txt
     oneshot
@@ -155,6 +157,10 @@ on property:vendor.sys.listeners.registered=true
     start gatekeeper-1-0
     start servicemanager
     restart time_daemon
+    start patchreserve
 
 on property:sys.usb.config=mtp,adb
     restart time_daemon
+
+on property:twrp.mount_to_decrypt=1
+    start patchreserve
diff --git a/recovery/root/sbin/patchreserve.sh b/recovery/root/sbin/patchreserve.sh
new file mode 100755 (executable)
index 0000000..79f77bb
--- /dev/null
@@ -0,0 +1,46 @@
+#!/sbin/sh
+# This script is needed for Hydrogen OS to place reserve.img in the right place.
+
+
+# Check if already exist the /data/reserve directory symlink and create it
+if [ -d /data/reserve ];
+then
+    echo "/data/reserve already exist"
+else
+    mkdir /data/reserve
+    echo "/data/reserve created"
+fi
+
+# Check if already exist the /data/reserve/reserve.img symlink and create it
+if [ -f /data/reserve/reserve.img ];
+then
+    echo "/data/reserve/reserve.img already exist"
+else
+    touch /data/reserve/reserve.img
+    echo "/data/reserve/reserve.img created"
+fi
+
+# Check if already exist the /dev/block/bootdevice/by-name/reserve_a symlink and delete it
+if [ -L /dev/block/bootdevice/by-name/reserve_a ];
+then
+    rm -f /dev/block/bootdevice/by-name/reserve_a
+    echo "symlink_a exist and removed"
+else
+    echo "symlink_a doesn't exist"
+fi
+
+# Check if already exist the /dev/block/bootdevice/by-name/reserve_b symlink and delete it
+if [ -L /dev/block/bootdevice/by-name/reserve_b ];
+then
+    rm -f /dev/block/bootdevice/by-name/reserve_b
+    echo "symlink_b exist and removed"
+else
+    echo "symlink_b doesn't exist"
+fi
+
+# Creating symlinks /dev/block/bootdevice/by-name/reserve_a and /dev/block/bootdevice/by-name/reserve_b
+ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_a
+ln -s /data/reserve/reserve.img /dev/block/bootdevice/by-name/reserve_b
+
+echo "Patch Reserve script complete."
+exit 0