diff --git a/module/common_func.sh b/module/common_func.sh new file mode 100644 index 0000000..7623096 --- /dev/null +++ b/module/common_func.sh @@ -0,0 +1,17 @@ +# resetprop_if_diff +resetprop_if_diff() { + local NAME="$1" + local EXPECTED="$2" + local CURRENT="$(resetprop "$NAME")" + + [ -z "$CURRENT" ] || [ "$CURRENT" = "$EXPECTED" ] || resetprop -n "$NAME" "$EXPECTED" +} + +# resetprop_if_match +resetprop_if_match() { + local NAME="$1" + local CONTAINS="$2" + local VALUE="$3" + + [[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && resetprop -n "$NAME" "$VALUE" +} diff --git a/module/post-fs-data.sh b/module/post-fs-data.sh index 2609c7d..25d3ae3 100644 --- a/module/post-fs-data.sh +++ b/module/post-fs-data.sh @@ -1,41 +1,37 @@ +MODPATH="${0%/*}" +. $MODPATH/common_func.sh + # Remove Play Services from Magisk DenyList when set to Enforce in normal mode if magisk --denylist status; then magisk --denylist rm com.google.android.gms fi -check_reset_prop() { - local NAME=$1 - local EXPECTED=$2 - local VALUE=$(resetprop $NAME) - [ -z $VALUE ] || [ $VALUE = $EXPECTED ] || resetprop $NAME $EXPECTED -} - # Conditional early sensitive properties # Samsung -check_reset_prop ro.boot.warranty_bit 0 -check_reset_prop ro.vendor.boot.warranty_bit 0 -check_reset_prop ro.vendor.warranty_bit 0 -check_reset_prop ro.warranty_bit 0 +resetprop_if_diff ro.boot.warranty_bit 0 +resetprop_if_diff ro.vendor.boot.warranty_bit 0 +resetprop_if_diff ro.vendor.warranty_bit 0 +resetprop_if_diff ro.warranty_bit 0 # Xiaomi -check_reset_prop ro.secureboot.lockstate locked +resetprop_if_diff ro.secureboot.lockstate locked # Realme -check_reset_prop ro.boot.realmebootstate green +resetprop_if_diff ro.boot.realmebootstate green # OnePlus -check_reset_prop ro.is_ever_orange 0 +resetprop_if_diff ro.is_ever_orange 0 # Microsoft for PROP in $(resetprop | grep -oE 'ro.*.build.tags'); do - check_reset_prop $PROP release-keys + resetprop_if_diff $PROP release-keys done # Other for PROP in $(resetprop | grep -oE 'ro.*.build.type'); do - check_reset_prop $PROP user + resetprop_if_diff $PROP user done -check_reset_prop ro.debuggable 0 -check_reset_prop ro.force.debuggable 0 -check_reset_prop ro.secure 1 +resetprop_if_diff ro.debuggable 0 +resetprop_if_diff ro.force.debuggable 0 +resetprop_if_diff ro.secure 1