MagiskHidePropsConf/common/propsconf_late

193 lines
4.5 KiB
Plaintext
Raw Normal View History

2018-03-18 15:39:43 +00:00
#!/system/bin/sh
# MagiskHide Props Config
2018-04-15 22:05:33 +00:00
# By Didgeridoohan @ XDA Developers
2018-03-18 15:39:43 +00:00
# This is a script file for the Magisk module "MagiskHide Props Config" By Didgeridoohan @ XDA Developers.
# DO NOT DELETE!
# Unless: If you don't have the module installed something has gone horribly wrong and this file is an orphan.
# In that case, feel free to delete it.
# Script version
2018-11-19 12:56:23 +00:00
SCRIPTV=19
2018-08-07 11:50:01 +00:00
SETTRANSF=2
NOTTRANSF="OPTIONLATE"
2018-03-18 15:39:43 +00:00
# Variables
2018-07-26 09:03:13 +00:00
COREPATH=CORE_PLACEHOLDER
IMGPATH=$COREPATH/img
2018-03-18 15:39:43 +00:00
MODPATH=$IMGPATH/MagiskHidePropsConf
2018-04-29 09:14:35 +00:00
CACHELOC=CACHE_PLACEHOLDER
2018-11-18 06:31:58 +00:00
POSTFILE=POST_PLACEHOLDER
2018-04-29 09:14:35 +00:00
LATELOGFILE=$CACHELOC/propsconf_latefile.log
2018-03-18 15:39:43 +00:00
FINGERPRINTENB=1
PRINTEDIT=0
BUILDPROPENB=1
FILESAFE=1
BUILDEDIT=0
DEFAULTEDIT=0
PROPCOUNT=0
PROPEDIT=0
2018-04-15 22:05:33 +00:00
CUSTOMEDIT=0
2018-06-19 09:56:08 +00:00
DELEDIT=0
2018-03-18 15:39:43 +00:00
REBOOTCHK=0
2018-08-07 11:50:01 +00:00
OPTIONLATE=0
2018-04-15 22:05:33 +00:00
OPTIONCOLOUR=1
OPTIONWEB=1
2018-05-29 07:29:19 +00:00
CACHEFILES="
propsconf.log
propsconf_last.log
propsconf_install.log
propsconf_conf
reset_mhpc
"
rm -f $LATELOGFILE
2018-04-15 22:05:33 +00:00
# Function to clean up different files after the module has been uninstalled
cleanup() {
2018-08-07 11:50:01 +00:00
echo "Cleaning up files in $CACHELOC." >> $LATELOGFILE 2>&1
2018-04-29 09:14:35 +00:00
for ITEM in $CACHEFILES; do
if [ -f "$CACHELOC/$ITEM" ]; then
2018-08-07 11:50:01 +00:00
echo "Deleting ${ITEM}." >> $LATELOGFILE 2>&1
rm -f $CACHELOC/$ITEM >> $LATELOGFILE 2>&1
2018-04-29 09:14:35 +00:00
fi
done
2018-04-15 22:05:33 +00:00
# Suicide.
2018-08-07 11:50:01 +00:00
echo "Removing scripts." >> $LATELOGFILE 2>&1
2018-11-18 06:31:58 +00:00
rm -f $POSTFILE >> $LATELOGFILE 2>&1
2018-08-07 11:50:01 +00:00
rm -f $0 >> $LATELOGFILE 2>&1
2018-04-15 22:05:33 +00:00
}
2018-03-18 15:39:43 +00:00
# Checks if the module is installed. Deletes itself if it isn't.
2018-04-15 22:05:33 +00:00
if [ -d "$MODPATH" ]; then
2018-03-18 15:39:43 +00:00
# Checks if the module is set for removal
2018-04-29 09:14:35 +00:00
if [ -f "$MODPATH/remove" ]; then
2018-08-07 11:50:01 +00:00
echo "Module set for removal." >> $LATELOGFILE 2>&1
2018-04-15 22:05:33 +00:00
# Cleanup
cleanup
2018-03-18 15:39:43 +00:00
else
# Load functions
. $MODPATH/util_functions.sh
2018-05-29 07:29:19 +00:00
if [ "$OPTIONLATE" == 0 ]; then
until [ ! -f "$POSTCHKFILE" ]; do
sleep 1
done
fi
2018-04-19 03:13:40 +00:00
log_script_chk "Running boot script."
2018-03-18 15:39:43 +00:00
2018-04-15 22:05:33 +00:00
if [ -f "$MODPATH/disable" ]; then
2018-04-29 09:14:35 +00:00
log_start
2018-04-15 22:05:33 +00:00
log_handler "Module disabled."
else
2018-05-29 07:29:19 +00:00
2018-04-25 22:17:32 +00:00
# Check the reboot variable
if [ "$(get_file_value $LATEFILE "REBOOTCHK\=")" == 1 ]; then
replace_fn REBOOTCHK 1 0 $LATEFILE
fi
2018-03-18 15:39:43 +00:00
# ---Original values---
# default.prop
2018-06-03 16:40:24 +00:00
ORIGDEBUGGABLE=""
ORIGSECURE=""
2018-03-18 15:39:43 +00:00
# build.prop
2018-06-03 16:40:24 +00:00
ORIGTYPE=""
ORIGTAGS=""
ORIGSELINUX=""
ORIGFINGERPRINT=""
2018-10-30 08:28:47 +00:00
ORIGPATCH=""
2018-03-18 15:39:43 +00:00
# ---Module values---
2018-04-15 22:05:33 +00:00
MODULEDEBUGGABLE=""
MODULESECURE=""
MODULETYPE=""
MODULETAGS=""
MODULESELINUX=""
MODULEFINGERPRINT=""
# ---Custom prop values---
CUSTOMPROPS=""
2018-09-04 07:55:57 +00:00
CUSTOMPROPSPOST=""
CUSTOMPROPSLATE=""
2018-06-19 09:56:08 +00:00
# ---Delete prop values---
DELETEPROPS=""
2018-04-15 22:05:33 +00:00
# ---MagiskHide sensitive props---
REDEBUGGABLE=false
RESECURE=false
RETYPE=false
RETAGS=false
RESELINUX=false
# ---Editing default.prop---
SETDEBUGGABLE=false
SETSECURE=false
# ---Editing build.prop---
SETTYPE=false
SETTAGS=false
SETSELINUX=false
2018-04-19 03:13:40 +00:00
SETFINGERPRINT=false
2018-03-18 15:39:43 +00:00
2018-05-29 07:29:19 +00:00
# Edits prop values if set for late_start service
2018-10-25 09:24:31 +00:00
echo -e "\n--------------------" >> $LOGFILE 2>&1
log_handler "Editing prop values in late_start service mode."
if [ "$OPTIONLATE" == 1 ]; then
# ---Setting/Changing fingerprint---
print_edit
# ---Setting custom props---
custom_edit "CUSTOMPROPS"
2018-05-29 07:29:19 +00:00
fi
2018-10-25 09:24:31 +00:00
# Edit custom props set for late_start service
custom_edit "CUSTOMPROPSLATE"
# 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 -v $ITEM >> $LOGFILE 2>&1
resetprop -nv $ITEM $(eval "echo \$$MODULEPROP") >> $LOGFILE 2>&1
fi
done
fi
echo -e "\n--------------------" >> $LOGFILE 2>&1
2018-04-15 22:05:33 +00:00
# ---Edits default.prop---
2018-03-18 15:39:43 +00:00
if [ "$DEFAULTEDIT" == 1 ] && [ "$FILESAFE" == 0 ]; then
log_handler "Editing default.prop."
mount -wo remount rootfs /
2018-04-29 09:14:35 +00:00
change_prop_file "default"
2018-03-18 15:39:43 +00:00
mount -ro remount rootfs /
else
log_handler "Default.prop editing disabled."
2018-04-29 09:14:35 +00:00
fi
2018-05-29 07:29:19 +00:00
2018-10-25 06:37:05 +00:00
# Get currently saved values
log_handler "Checking current values."
curr_values
2018-06-19 09:56:08 +00:00
2018-10-25 06:37:05 +00:00
# Check if the late_start service log file exists.
if [ -f "$LATELOGFILE" ]; then
log_handler "Removing late_start service log ($LATELOGFILE)."
rm -f $LATELOGFILE >> $LOGFILE 2>&1
2018-10-21 14:17:11 +00:00
fi
2018-10-25 06:37:05 +00:00
log_script_chk "Boot script finished.\n\n=================="
2018-10-21 14:17:11 +00:00
fi
fi
else
echo "$MODPATH not found." >> $LATELOGFILE 2>&1
echo "Module no longer installed." >> $LATELOGFILE 2>&1
# Cleanup
cleanup
fi