MagiskHidePropsConf/common/service.sh

109 lines
3.0 KiB
Bash
Raw Normal View History

2019-02-02 12:37:20 +00:00
#!/system/bin/sh
# MagiskHide Props Config
# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers
# Licence: MIT
2019-03-27 10:50:00 +00:00
MODPATH=${0%/*}
2019-04-02 19:42:29 +00:00
BOOTSTAGE="late"
2019-03-27 10:50:00 +00:00
2019-02-02 12:37:20 +00:00
# Load functions
. $MODPATH/util_functions.sh
2019-11-22 19:19:18 +00:00
TMP_WAIT=0
until [ ! -f "$POSTCHKFILE" ] || [ "$TMP_WAIT" == 10 ]; do
sleep 1
TMP_WAIT=$(($TMP_WAIT + 1))
done
2019-02-02 12:37:20 +00:00
log_script_chk "Running service.sh module script."
2019-11-22 19:19:18 +00:00
# Resets the reboot and print update variables in propsconf_late
replace_fn REBOOTCHK 1 0 $LATEFILE
replace_fn PRINTCHK 1 0 $LATEFILE
2019-11-02 22:24:17 +00:00
# Retrieving default values from props file
log_handler "Saving device default values."
default_save
log_handler "Default values saved to $LATEFILE."
2019-11-22 19:19:18 +00:00
# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint
PRINTMODULE=false
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)."
PRINTMODULE=true
fi
fi
done
if [ "$PRINTMODULE" == "true" ]; then
replace_fn FINGERPRINTENB 1 0 $LATEFILE
replace_fn PRINTMODULE 0 1 $LATEFILE
log_handler "Fingerprint modification disabled."
else
replace_fn FINGERPRINTENB 0 1 $LATEFILE
replace_fn PRINTMODULE 1 0 $LATEFILE
fi
# Checks for configuration file
config_file
2019-02-02 12:37:20 +00:00
# Edits prop values if set for late_start service
2019-04-02 19:42:29 +00:00
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
2019-02-02 12:37:20 +00:00
log_handler "Editing prop values in late_start service mode."
2019-03-27 10:50:00 +00:00
if [ "$OPTIONBOOT" == 2 ]; then
2019-02-02 12:37:20 +00:00
# ---Setting/Changing fingerprint---
2019-03-27 10:50:00 +00:00
if [ "$PRINTSTAGE" == 0 ]; then
print_edit
fi
2019-04-02 19:42:29 +00:00
# ---Setting/Changing security patch date---
if [ "$PATCHSTAGE" == 0 ]; then
patch_edit
fi
2019-02-02 12:37:20 +00:00
# ---Setting device simulation props---
2019-03-27 10:50:00 +00:00
if [ "$SIMSTAGE" == 0 ]; then
dev_sim_edit
fi
2019-02-02 12:37:20 +00:00
# ---Setting custom props---
custom_edit "CUSTOMPROPS"
fi
2019-03-27 10:50:00 +00:00
# Edit fingerprint if set for late_start service
if [ "$OPTIONBOOT" != 2 ] && [ "$PRINTSTAGE" == 2 ]; then
print_edit
fi
2019-04-02 19:42:29 +00:00
# Edit security patch date if set for late_start service
if [ "$OPTIONBOOT" != 2 ] && [ "$PATCHSTAGE" == 2 ]; then
patch_edit
fi
2019-03-27 10:50:00 +00:00
# Edit simulation props if set for late_start service
if [ "$OPTIONBOOT" != 2 ] && [ "$SIMSTAGE" == 2 ]; then
dev_sim_edit
fi
2019-02-02 12:37:20 +00:00
# Edit custom props set for late_start service
custom_edit "CUSTOMPROPSLATE"
2019-11-22 19:19:18 +00:00
2019-02-02 12:37:20 +00:00
# Edit MagiskHide sensitive values
if [ "$PROPEDIT" == 1 ]; then
log_handler "Changing sensitive props."
for ITEM in $PROPSLIST; do
PROP=$(get_prop_type $ITEM)
REPROP=$(echo "RE${PROP}" | tr '[:lower:]' '[:upper:]')
MODULEPROP=$(echo "MODULE${PROP}" | tr '[:lower:]' '[:upper:]')
if [ "$(eval "echo \$$REPROP")" == "true" ]; then
log_handler "Changing/writing $ITEM."
resetprop -nv $ITEM $(eval "echo \$$MODULEPROP") >> $LOGFILE 2>&1
fi
done
fi
2019-04-02 19:42:29 +00:00
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
2019-02-02 12:37:20 +00:00
# Get currently saved values
log_handler "Checking current values."
curr_values
2019-04-02 19:42:29 +00:00
# Check system.prop content
system_prop_cont
2019-02-02 12:37:20 +00:00
2019-11-22 19:19:18 +00:00
log_script_chk "service.sh module script finished."