PlayIntegrityFix/module/service.sh

65 lines
1.8 KiB
Bash
Raw Normal View History

# Conditional sensitive properties
2023-11-24 21:58:30 +02:00
resetprop_if_diff() {
2024-02-08 13:33:37 +02:00
local NAME="$1"
local EXPECTED="$2"
local CURRENT="$(resetprop "$NAME")"
[ -z "$CURRENT" ] || [ "$CURRENT" = "$EXPECTED" ] || resetprop "$NAME" "$EXPECTED"
2023-11-24 21:58:30 +02:00
}
2023-11-30 19:28:01 +02:00
resetprop_if_match() {
2024-02-08 13:33:37 +02:00
local NAME="$1"
local CONTAINS="$2"
local VALUE="$3"
[[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && resetprop "$NAME" "$VALUE"
}
2023-11-24 21:58:30 +02:00
# Magisk recovery mode
resetprop_if_match ro.bootmode recovery unknown
resetprop_if_match ro.boot.mode recovery unknown
resetprop_if_match vendor.boot.mode recovery unknown
2023-11-24 21:58:30 +02:00
# SELinux
if [ -n "$(resetprop ro.build.selinux)" ]; then
resetprop --delete ro.build.selinux
fi
2023-11-30 19:28:01 +02:00
# use toybox to protect *stat* access time reading
if [ "$(toybox cat /sys/fs/selinux/enforce)" == "0" ]; then
2023-11-25 03:13:22 +02:00
chmod 640 /sys/fs/selinux/enforce
chmod 440 /sys/fs/selinux/policy
fi
2024-02-08 13:33:37 +02:00
# Conditional late sensitive properties
2024-02-08 13:33:37 +02:00
# SafetyNet/Play Integrity
{
# must be set after boot_completed for various OEMs
until [ "$(getprop sys.boot_completed)" = "1" ]; do
sleep 1
done
2024-02-08 13:33:37 +02:00
# avoid breaking Realme fingerprint scanners
resetprop_if_diff ro.boot.flash.locked 1
resetprop_if_diff ro.boot.realme.lockstate 1
2023-12-28 02:18:58 +02:00
2024-02-08 13:33:37 +02:00
# avoid breaking Oppo fingerprint scanners
resetprop_if_diff ro.boot.vbmeta.device_state locked
2024-01-12 14:32:32 +02:00
2024-02-08 13:33:37 +02:00
# avoid breaking OnePlus display modes/fingerprint scanners
resetprop_if_diff vendor.boot.verifiedbootstate green
2024-01-12 14:32:32 +02:00
2024-02-08 13:33:37 +02:00
# avoid breaking OnePlus/Oppo display fingerprint scanners on OOS/ColorOS 12+
resetprop_if_diff ro.boot.verifiedbootstate green
resetprop_if_diff ro.boot.veritymode enforcing
resetprop_if_diff vendor.boot.vbmeta.device_state locked
# Xiaomi
resetprop_if_diff ro.secureboot.lockstate locked
2024-01-12 14:32:32 +02:00
2024-02-08 13:33:37 +02:00
# Realme
resetprop_if_diff ro.boot.realmebootstate green
}&