MagiskHidePropsConf/common/post-fs-data.sh

126 lines
3.2 KiB
Bash
Raw Normal View History

2017-12-25 21:21:25 +00:00
#!/system/bin/sh
2018-03-18 15:39:43 +00:00
# MagiskHide Props Config
2019-02-02 12:37:20 +00:00
# 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="post"
2019-03-27 10:50:00 +00:00
2019-02-02 12:37:20 +00:00
# Load functions
. $MODPATH/util_functions.sh
2018-03-18 15:39:43 +00:00
2019-02-02 12:37:20 +00:00
# Start logging
log_start
2019-04-02 19:42:29 +00:00
bb_check
2018-03-18 15:39:43 +00:00
2019-02-02 12:37:20 +00:00
# Clears out the script check file
rm -f $RUNFILE
touch $RUNFILE
2018-03-18 15:39:43 +00:00
2019-02-02 12:37:20 +00:00
# Clears out the script control file
touch $POSTCHKFILE
# Checks the reboot and print update variables in propsconf_late
if [ "$REBOOTCHK" == 1 ]; then
replace_fn REBOOTCHK 1 0 $LATEFILE
fi
if [ "$PRINTCHK" == 1 ]; then
replace_fn PRINTCHK 1 0 $LATEFILE
2018-05-29 07:29:19 +00:00
fi
2019-02-02 12:37:20 +00:00
# Check for the boot script and restore backup if deleted, or if the resetfile is present
2019-11-02 22:24:17 +00:00
RESETFILE=""
for ITEM in $RESETFILELST; do
if [ -f "$ITEM" ]; then
RESETFILE="$ITEM"
break
fi
done
2018-04-15 22:05:33 +00:00
if [ ! -f "$LATEFILE" ] || [ -f "$RESETFILE" ]; then
2018-04-25 22:17:32 +00:00
if [ -f "$RESETFILE" ]; then
2018-05-29 07:29:19 +00:00
RSTTXT="Resetting"
2019-11-02 22:24:17 +00:00
for ITEM in $RESETFILELST; do
rm -f $ITEM
done
2018-04-25 22:17:32 +00:00
else
2018-05-29 07:29:19 +00:00
RSTTXT="Restoring"
2019-05-04 18:57:59 +00:00
log_handler "The module settings file could not be found."
2018-05-29 07:29:19 +00:00
fi
2019-05-04 18:57:59 +00:00
log_handler "$RSTTXT module settings file (${LATEFILE})."
2018-08-07 11:50:01 +00:00
cp -af $MODPATH/propsconf_late $LATEFILE >> $LOGFILE 2>&1
2019-11-02 22:24:17 +00:00
rm -f $MODPATH/system.prop >> $LOGFILE 2>&1
2018-12-22 18:41:34 +00:00
fi
2019-02-02 12:37:20 +00:00
# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint
PRINTMODULE=false
for USNF in $USNFLIST; do
2019-04-05 21:10:02 +00:00
if [ -d "$MODULESPATH/$USNF" ]; then
2019-05-04 18:57:59 +00:00
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
2019-02-02 12:37:20 +00:00
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
2019-11-02 22:24:17 +00:00
# Save default values
log_handler "Saving device prop values."
resetprop > $MHPCPATH/defaultprops
log_handler "Prop values saved to $MHPCPATH/defaultprops."
2019-02-02 12:37:20 +00:00
2019-11-02 22:24:17 +00:00
# Loading module settings
2019-02-02 12:37:20 +00:00
. $LATEFILE
# Checks for configuration file
config_file
# Edits prop values if set for post-fs-data
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 post-fs-data mode."
2019-03-27 10:50:00 +00:00
if [ "$OPTIONBOOT" == 1 ]; 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 post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$PRINTSTAGE" == 1 ]; then
print_edit
fi
2019-04-02 19:42:29 +00:00
# Edit security patch date if set for post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$PATCHSTAGE" == 1 ]; then
patch_edit
fi
2019-03-27 10:50:00 +00:00
# Edit simulation props if set for post-fs-data
if [ "$OPTIONBOOT" != 1 ] && [ "$SIMSTAGE" == 1 ]; then
dev_sim_edit
fi
2019-02-02 12:37:20 +00:00
# Edit custom props set for post-fs-data
custom_edit "CUSTOMPROPSPOST"
2019-03-27 10:50:00 +00:00
# Deleting props
prop_del
2019-04-02 19:42:29 +00:00
echo -e "\n----------------------------------------" >> $LOGFILE 2>&1
2019-02-02 12:37:20 +00:00
log_script_chk "post-fs-data.sh module script finished.\n\n===================="
2018-03-18 15:39:43 +00:00
2018-05-29 07:29:19 +00:00
# Deletes the post-fs-data control file
2019-02-02 12:37:20 +00:00
rm -f $POSTCHKFILE