MagiskHidePropsConf/service.sh

160 lines
4.1 KiB
Bash
Raw Normal View History

2020-01-10 18:45:27 +00:00
#!/system/bin/sh
# MagiskHide Props Config
2021-09-04 11:11:35 +00:00
# Copyright (c) 2018-2021 Didgeridoohan @ XDA Developers
2020-01-10 18:45:27 +00:00
# Licence: MIT
MODPATH=${0%/*}
BOOTSTAGE="late"
2020-03-06 12:37:19 +00:00
# Variables
MODULESPATH=${MODPATH%/*}
ADBPATH=${MODULESPATH%/*}
MHPCPATH=$ADBPATH/mhpc
2020-01-26 09:36:26 +00:00
2020-01-10 18:45:27 +00:00
TMP_WAIT=0
2020-03-06 12:37:19 +00:00
while [ ! -f "$MHPCPATH/propsconf_postchk" ] && [ "$TMP_WAIT" -lt 10 ]; do
2020-01-10 18:45:27 +00:00
sleep 1
TMP_WAIT=$(($TMP_WAIT + 1))
done
2020-03-06 12:37:19 +00:00
# Load functions
. $MODPATH/common/util_functions.sh
2020-01-10 18:45:27 +00:00
log_script_chk "Running service.sh module script."
2021-09-04 11:11:35 +00:00
# Check for reboot flag
if [ -f "$MHPCPATH/reboot" ]; then
rm -f $MHPCPATH/reboot >> $LOGFILE 2>&1
force_reboot
fi
2020-01-10 18:45:27 +00:00
# Resets the reboot and print update variables in propsconf_late
replace_fn REBOOTCHK 1 0 $LATEFILE
replace_fn PRINTCHK 1 0 $LATEFILE
# Retrieving default values from props file
log_handler "Saving device default values."
default_save
log_handler "Default values saved to $LATEFILE."
# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint
2020-01-17 08:44:46 +00:00
TMPUSNF=false
2020-01-10 18:45:27 +00:00
for USNF in $USNFLIST; do
if [ -d "$MODULESPATH/$USNF" ]; then
if [ ! -f "$MODULESPATH/$USNF/disable" ]; then
NAME=$(get_file_value $MODULESPATH/$USNF/module.prop "name=")
log_handler "Magisk module '$NAME' installed (modifies the device fingerprint)."
2020-01-17 08:44:46 +00:00
TMPUSNF=true
2020-01-10 18:45:27 +00:00
fi
fi
done
2020-01-17 08:44:46 +00:00
if [ "$TMPUSNF" == "true" ]; then
2020-01-10 18:45:27 +00:00
replace_fn FINGERPRINTENB 1 0 $LATEFILE
replace_fn PRINTMODULE 0 1 $LATEFILE
log_handler "Fingerprint modification disabled."
2020-01-17 08:44:46 +00:00
# Reset current fingerprint if set
if [ "$MODULEFINGERPRINT" ]; then
log_handler "Resetting current fingerprint."
reset_print
force_reboot
fi
2020-01-10 18:45:27 +00:00
else
replace_fn FINGERPRINTENB 0 1 $LATEFILE
replace_fn PRINTMODULE 1 0 $LATEFILE
fi
# Checks for configuration file
config_file
# Edits prop values if set for late_start service
2021-09-04 11:11:35 +00:00
PROPLATE=false
2020-01-10 18:45:27 +00:00
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
log_handler "Editing prop values in late_start service mode."
if [ "$OPTIONBOOT" == 2 ]; then
2021-09-04 11:11:35 +00:00
# ---Setting/Changing fingerprint---
2020-01-10 18:45:27 +00:00
if [ "$PRINTSTAGE" == 0 ]; then
2020-03-06 12:37:19 +00:00
print_edit "none"
2020-01-10 18:45:27 +00:00
fi
# ---Setting/Changing security patch date---
if [ "$PATCHSTAGE" == 0 ]; then
2020-03-06 12:37:19 +00:00
patch_edit "none"
2020-01-10 18:45:27 +00:00
fi
2020-07-26 18:53:37 +00:00
# Forced basic attestation
if [ "$BASICATTEST" == 1 ]; then
forced_basic "none"
fi
2020-01-10 18:45:27 +00:00
# ---Setting device simulation props---
if [ "$SIMSTAGE" == 0 ]; then
2020-03-06 12:37:19 +00:00
dev_sim_edit "none"
2020-01-10 18:45:27 +00:00
fi
# ---Setting custom props---
custom_edit "CUSTOMPROPS"
2021-09-04 11:11:35 +00:00
else
# Edit fingerprint if set for late_start service
if [ "$PRINTSTAGE" == 2 ]; then
print_edit "none"
fi
# Edit security patch date if set for late_start service
if [ "$PATCHSTAGE" == 2 ]; then
patch_edit "none"
fi
# Edit simulation props if set for late_start service
if [ "$SIMSTAGE" == 2 ]; then
dev_sim_edit "none"
fi
2020-01-10 18:45:27 +00:00
fi
2021-09-04 11:11:35 +00:00
# Edit MagiskHide sensitive props
if [ "$PROPEDIT" == 1 ]; then
# Edit all sensitive props, if set for late_start service
2021-09-20 17:38:22 +00:00
if [ "$PROPBOOT" == 2 ]; then
2021-09-06 17:19:37 +00:00
sensitive_props "$PROPSLIST"
2021-09-04 11:11:35 +00:00
fi
2021-09-20 17:38:22 +00:00
if [ "$PROPBOOT" == 0 ] || [ "$PROPBOOT" == 2 ]; then
sensitive_props "$TRIGGERPROPS"
fi
2021-09-04 11:11:35 +00:00
# Edit late senstive props
2021-09-20 17:38:22 +00:00
{
until [ $(getprop sys.boot_completed) == 1 ]; do
sleep 1
done
2021-09-06 17:19:37 +00:00
sensitive_props "$LATEPROPS" "late"
2021-09-20 17:38:22 +00:00
}&
2020-01-10 18:45:27 +00:00
fi
2021-09-04 11:11:35 +00:00
2021-09-05 07:27:36 +00:00
# Edit custom props set for late_start service
custom_edit "CUSTOMPROPSLATE"
custom_edit "CUSTOMPROPSDELAY"
2021-09-04 11:11:35 +00:00
# SELinux
2021-09-20 17:38:22 +00:00
# Remove ro.build.selinux if present
if [ "$(grep "ro.build.selinux" $MHPCPATH/defaultprops)" ]; then
log_handler "Removing ro.build.selinux."
resetprop -v --delete ro.build.selinux >> $LOGFILE 2>&1
fi
# Check for permissive SELinux
2021-09-04 11:11:35 +00:00
if [ "$(getenforce)" == "Permissive" ] || [ "$(getenforce)" == "0" ]; then
log_handler "Dealing with permissive SELinux."
chmod 640 /sys/fs/selinux/enforce >> $LOGFILE 2>&1
chmod 440 /sys/fs/selinux/policy >> $LOGFILE 2>&1
2020-01-10 18:45:27 +00:00
fi
2021-09-04 11:11:35 +00:00
2021-09-06 17:19:37 +00:00
# Do a soft restart if the option is active and a prop has been set in service.sh
2021-09-05 07:27:36 +00:00
if [ "$PROPLATE" == "true" ]; then
log_handler "Soft rebooting."
stop
start
fi
2020-01-10 18:45:27 +00:00
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
# Get currently saved values
log_handler "Checking current values."
curr_values
# Check system.prop content
system_prop_cont
log_script_chk "service.sh module script finished."