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
#anch1
MODPATH = ${ 0 %/* }
BOOTSTAGE = "post"
# Variables
MODULESPATH = ${ MODPATH %/* }
ADBPATH = ${ MODULESPATH %/* }
MHPCPATH = $ADBPATH /mhpc
LOGFILE = $MHPCPATH /propsconf.log
LASTLOGFILE = $MHPCPATH /propsconf_last.log
2020-01-26 09:36:26 +00:00
VLOGFILE = $MHPCPATH /propsconf_boot_verbose.log
VLASTLOGFILE = $MHPCPATH /propsconf_boot_verbose_last.log
2020-01-10 18:45:27 +00:00
RUNFILE = $MHPCPATH /script_check
# Placeholder variables
MODVERSIONPH = VER_PLACEHOLDER
LATEFILEPH = LATE_PLACEHOLDER
2021-09-04 11:11:35 +00:00
# Sensitive props
TRIGGERLIST = "
ro.bootmode= recovery
ro.boot.mode= recovery
vendor.boot.mode= recovery
ro.boot.hwc= CN
ro.boot.hwcountry= China
"
2020-01-10 18:45:27 +00:00
# Saves the previous log (if available) and creates a new one
if [ -f " $LOGFILE " ] ; then
mv -f $LOGFILE $LASTLOGFILE
fi
2020-05-21 19:02:54 +00:00
# Run the boot logcat script
. $MODPATH /common/bootlog.sh
#Start logging
2020-01-10 18:45:27 +00:00
echo "***************************************************" > $LOGFILE 2>& 1
echo " ********* MagiskHide Props Config $MODVERSION ******** " >> $LOGFILE 2>& 1
echo "***************** By Didgeridoohan ***************" >> $LOGFILE 2>& 1
echo "***************************************************" >> $LOGFILE 2>& 1
echo ""
2020-08-14 08:01:35 +00:00
STRST = " $( date +"%m-%d-%Y %H:%M:%S.%3N" ) - Log start (regular execution). "
2020-01-10 18:45:27 +00:00
echo -e $STRST >> $LOGFILE 2>& 1
echo -e $STRST > $RUNFILE 2>& 1
# Save default prop values
2020-03-01 19:50:53 +00:00
getprop > $MHPCPATH /defaultprops
2020-01-10 18:45:27 +00:00
echo "" >> $LOGFILE 2>& 1
2020-08-14 08:01:35 +00:00
echo -e " $( date +"%Y-%m-%d %H:%M:%S.%3N" ) - Saved default values " >> $LOGFILE 2>& 1
2020-01-10 18:45:27 +00:00
{
# Creates/updates the script control file
2020-03-06 12:37:19 +00:00
touch $MHPCPATH /propsconf_postchk >> $LOGFILE 2>& 1
2020-01-10 18:45:27 +00:00
# Logging
log_handler( ) {
echo "" >> $LOGFILE 2>& 1
2020-08-14 08:01:35 +00:00
echo -e " $( date +"%Y-%m-%d %H:%M:%S.%3N" ) - $1 " >> $LOGFILE 2>& 1
2020-01-10 18:45:27 +00:00
}
2021-09-04 11:11:35 +00:00
# Get left side of =, $1=string to check
get_eq_left( ) {
echo $1 | cut -f 1 -d '='
}
# Get right side of =, $1=string to check
get_eq_right( ) {
echo $1 | cut -f 2- -d '='
}
# Finding file values, $1=file (with path), $2=string to look for
get_file_value( ) {
if [ -f " $1 " ] ; then
echo $( grep $2 $1 ) | sed " s|.* ${ 2 } || " | sed 's|\"||g'
fi
}
# Find prop type, $1=prop name
get_prop_type( ) {
if [ " $1 " = = "vendor.boot.mode" ] ; then
echo "vendormode"
else
echo $1 | sed 's|.*\.||' | sed 's|.*\_||'
fi
}
2020-03-06 12:37:19 +00:00
# Reset/disable file locations
FILELOCLST = "
/data/media/0
/data
$CACHELOC
2020-01-10 18:45:27 +00:00
"
2020-03-06 12:37:19 +00:00
# Check if disable file is present
DISABLEFILE = ""
for ITEM in $FILELOCLST ; do
if [ -f " $ITEM /disable_mhpc " ] ; then
DISABLEFILE = " $ITEM /disable_mhpc "
break
fi
done
if [ -f " $DISABLEFILE " ] ; then
log_handler "Disable file found. Disabling module..."
touch $MODPATH /disable
for ITEM in $FILELOCLST ; do
rm -f $ITEM /disable_mhpc
done
# Deletes the post-fs-data control file
rm -f $MHPCPATH /propsconf_postchk >> $LOGFILE 2>& 1
# Reboot
2021-09-04 11:11:35 +00:00
log_handler "Setting reboot flag."
touch $MHPCPATH /reboot >> $LOGFILE 2>& 1
2020-03-06 12:37:19 +00:00
fi
# Check for the boot script and restore backup if deleted, or if the reset file is present
2020-01-10 18:45:27 +00:00
RESETFILE = ""
2020-03-06 12:37:19 +00:00
for ITEM in $FILELOCLST ; do
if [ -f " $ITEM /reset_mhpc " ] ; then
RESETFILE = " $ITEM /reset_mhpc "
2020-01-10 18:45:27 +00:00
break
fi
done
if [ ! -s " $LATEFILE " ] || [ -f " $RESETFILE " ] ; then
if [ -f " $RESETFILE " ] ; then
2020-03-06 12:37:19 +00:00
log_handler "Reset file found."
2020-01-10 18:45:27 +00:00
RSTTXT = "Resetting"
2020-03-06 12:37:19 +00:00
for ITEM in $FILELOCLST ; do
rm -f $ITEM /reset_mhpc
2020-01-10 18:45:27 +00:00
done
else
RSTTXT = "Restoring"
if [ -f " $LATEFILE " ] ; then
log_handler "The module settings file was empty."
else
log_handler "The module settings file could not be found."
fi
2021-09-04 11:11:35 +00:00
fi
2020-01-10 18:45:27 +00:00
log_handler " $RSTTXT module settings file ( ${ LATEFILE } ). "
cp -af $MODPATH /common/propsconf_late $LATEFILE >> $LOGFILE 2>& 1
rm -f $MODPATH /system.prop >> $LOGFILE 2>& 1
fi
# Loading module settings
2021-09-04 11:11:35 +00:00
log_handler "Loading module settings"
2020-01-10 18:45:27 +00:00
. $LATEFILE
# Edits prop values if set for post-fs-data
2021-09-04 11:11:35 +00:00
if [ " $OPTIONBOOT " = = 1 ] || [ " $OPTIONBOOT " != 1 -a " $PRINTSTAGE " = = 1 ] || [ " $OPTIONBOOT " != 1 -a " $PATCHSTAGE " = = 1 ] || [ " $OPTIONBOOT " != 1 -a " $SIMSTAGE " = = 1 ] || [ " $CUSTOMPROPSPOST " ] || [ " $DELETEPROPS " ] || [ " $PROPBOOT " = = 1 ] ; then
2020-01-10 18:45:27 +00:00
# Load functions
. $MODPATH /common/util_functions.sh
echo -e "\n----------------------------------------" >> $LOGFILE 2>& 1
log_handler "Editing prop values in post-fs-data mode."
if [ " $OPTIONBOOT " = = 1 ] ; then
# Setting/Changing fingerprint
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 post-fs-data
if [ " $PRINTSTAGE " = = 1 ] ; then
print_edit "none"
fi
# Edit security patch date if set for post-fs-data
if [ " $PATCHSTAGE " = = 1 ] ; then
patch_edit "none"
fi
# Edit simulation props if set for post-fs-data
if [ " $SIMSTAGE " = = 1 ] ; 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 set for post-fs-data
if [ " $PROPEDIT " = = 1 ] && [ " $PROPBOOT " = = 1] ; then
2021-09-20 17:38:22 +00:00
sensitive_props " $PROPSLIST $TRIGGERLIST "
2020-01-10 18:45:27 +00:00
fi
# Edit custom props set for post-fs-data
custom_edit "CUSTOMPROPSPOST"
# Deleting props
prop_del
echo -e "\n----------------------------------------" >> $LOGFILE 2>& 1
fi
2021-09-04 11:11:35 +00:00
log_handler "post-fs-data.sh module script finished."
echo -e " \n $( date +"%Y-%m-%d %H:%M:%S:%N" ) - post-fs-data.sh module script finished. " >> $RUNFILE 2>& 1
2020-01-10 18:45:27 +00:00
# Deletes the post-fs-data control file
2020-03-06 12:37:19 +00:00
rm -f $MHPCPATH /propsconf_postchk >> $LOGFILE 2>& 1
2020-01-10 18:45:27 +00:00
} &