Refactor post-fs-data.sh

This commit is contained in:
chiteroman 2024-07-22 11:50:45 +02:00
parent 714ae3bfa2
commit 7cb8c51905
2 changed files with 19 additions and 32 deletions

View File

@ -1,17 +0,0 @@
# resetprop_if_diff <prop name> <expected value>
resetprop_if_diff() {
local NAME="$1"
local EXPECTED="$2"
local CURRENT="$(resetprop "$NAME")"
[ -z "$CURRENT" ] || [ "$CURRENT" = "$EXPECTED" ] || resetprop -n "$NAME" "$EXPECTED"
}
# resetprop_if_match <prop name> <value match string> <new value>
resetprop_if_match() {
local NAME="$1"
local CONTAINS="$2"
local VALUE="$3"
[[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && resetprop -n "$NAME" "$VALUE"
}

View File

@ -1,37 +1,41 @@
MODPATH="${0%/*}"
. $MODPATH/common_func.sh
# Remove Play Services from Magisk DenyList when set to Enforce in normal mode # Remove Play Services from Magisk DenyList when set to Enforce in normal mode
if magisk --denylist status; then if magisk --denylist status; then
magisk --denylist rm com.google.android.gms magisk --denylist rm com.google.android.gms
fi 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 # Conditional early sensitive properties
# Samsung # Samsung
resetprop_if_diff ro.boot.warranty_bit 0 check_reset_prop ro.boot.warranty_bit 0
resetprop_if_diff ro.vendor.boot.warranty_bit 0 check_reset_prop ro.vendor.boot.warranty_bit 0
resetprop_if_diff ro.vendor.warranty_bit 0 check_reset_prop ro.vendor.warranty_bit 0
resetprop_if_diff ro.warranty_bit 0 check_reset_prop ro.warranty_bit 0
# Xiaomi # Xiaomi
resetprop_if_diff ro.secureboot.lockstate locked check_reset_prop ro.secureboot.lockstate locked
# Realme # Realme
resetprop_if_diff ro.boot.realmebootstate green check_reset_prop ro.boot.realmebootstate green
# OnePlus # OnePlus
resetprop_if_diff ro.is_ever_orange 0 check_reset_prop ro.is_ever_orange 0
# Microsoft # Microsoft
for PROP in $(resetprop | grep -oE 'ro.*.build.tags'); do for PROP in $(resetprop | grep -oE 'ro.*.build.tags'); do
resetprop_if_diff $PROP release-keys check_reset_prop $PROP release-keys
done done
# Other # Other
for PROP in $(resetprop | grep -oE 'ro.*.build.type'); do for PROP in $(resetprop | grep -oE 'ro.*.build.type'); do
resetprop_if_diff $PROP user check_reset_prop $PROP user
done done
resetprop_if_diff ro.debuggable 0 check_reset_prop ro.debuggable 0
resetprop_if_diff ro.force.debuggable 0 check_reset_prop ro.force.debuggable 0
resetprop_if_diff ro.secure 1 check_reset_prop ro.secure 1