mirror of
https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf.git
synced 2024-11-19 14:14:33 +00:00
157 lines
5.3 KiB
Bash
157 lines
5.3 KiB
Bash
#!/system/bin/sh
|
|
|
|
# MagiskHide Props Config
|
|
# By Didgeridoohan @ XDA Developers
|
|
|
|
# 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.
|
|
|
|
# Variables
|
|
COREPATH=CORE_PLACEHOLDER
|
|
IMGPATH=$COREPATH/img
|
|
MODPATH=$IMGPATH/MagiskHidePropsConf
|
|
POSTLOGFILE=$CACHELOC/propsconf_postfile.log
|
|
|
|
# Checks if the module is installed. Deletes itself if it isn't.
|
|
if [ -d "$MODPATH" ]; then
|
|
# Checks if the module is set for removal
|
|
if [ -f "$MODPATH/remove" ]; then
|
|
echo "Module set for removal." >> $POSTLOGFILE 2>&1
|
|
else
|
|
# Load functions
|
|
. $MODPATH/util_functions.sh
|
|
|
|
# Clears out the script check file
|
|
rm -f $RUNFILE
|
|
touch $RUNFILE
|
|
|
|
# Start logging
|
|
log_start
|
|
|
|
if [ -f "$MODPATH/disable" ]; then
|
|
log_start
|
|
log_handler "Module disabled."
|
|
else
|
|
# Clears out the script control file
|
|
rm -f $POSTCHKFILE
|
|
touch $POSTCHKFILE
|
|
|
|
# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint
|
|
PRINTMODULE=false
|
|
for USNF in $USNFLIST; do
|
|
if [ -d "$IMGPATH/$USNF" ]; then
|
|
NAME=$(get_file_value $IMGPATH/$USNF/module.prop "name=")
|
|
log_handler "'$NAME' installed (modifies the device fingerprint)."
|
|
PRINTMODULE=true
|
|
fi
|
|
done
|
|
if [ "$PRINTMODULE" == "true" ]; then
|
|
replace_fn FINGERPRINTENB 1 0 $LATEFILE
|
|
log_handler "Fingerprint modification disabled."
|
|
else
|
|
replace_fn FINGERPRINTENB 0 1 $LATEFILE
|
|
fi
|
|
|
|
# Get default values
|
|
log_handler "Checking device default values."
|
|
curr_values
|
|
# Get the current original values saved in propsconf_late
|
|
log_handler "Checking currently saved values."
|
|
orig_values
|
|
|
|
# Save default file values in propsconf_late
|
|
replace_fn ORIGDEBUGGABLE "\"$ORIGDEBUGGABLE\"" "\"$CURRDEBUGGABLE\"" $LATEFILE
|
|
replace_fn ORIGSECURE "\"$ORIGSECURE\"" "\"$CURRSECURE\"" $LATEFILE
|
|
replace_fn ORIGTYPE "\"$ORIGTYPE\"" "\"$CURRTYPE\"" $LATEFILE
|
|
replace_fn ORIGTAGS "\"$ORIGTAGS\"" "\"$CURRTAGS\"" $LATEFILE
|
|
replace_fn ORIGSELINUX "\"$ORIGSELINUX\"" "\"$CURRSELINUX\"" $LATEFILE
|
|
replace_fn ORIGFINGERPRINT "\"$ORIGFINGERPRINT\"" "\"$CURRFINGERPRINT\"" $LATEFILE
|
|
replace_fn ORIGPATCH "\"$ORIGPATCH\"" "\"$CURRPATCH\"" $LATEFILE
|
|
log_handler "Default values saved to $LATEFILE."
|
|
# Loading the new values
|
|
orig_values
|
|
|
|
# Check if original file values are safe
|
|
orig_safe
|
|
|
|
# Checks for configuration file
|
|
config_file
|
|
|
|
# Edits prop values if set for post-fs-data
|
|
echo -e "\n--------------------" >> $LOGFILE 2>&1
|
|
log_handler "Editing prop values in post-fs-data mode."
|
|
if [ "$(get_file_value $LATEFILE "OPTIONLATE=")" == 0 ]; then
|
|
# ---Setting/Changing fingerprint---
|
|
print_edit
|
|
# ---Setting custom props---
|
|
custom_edit "CUSTOMPROPS"
|
|
fi
|
|
# Deleting props
|
|
prop_del
|
|
# Edit custom props set for post-fs-data
|
|
custom_edit "CUSTOMPROPSPOST"
|
|
echo -e "\n--------------------" >> $LOGFILE 2>&1
|
|
|
|
# Edits build.prop
|
|
if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then
|
|
log_handler "Checking for conflicting build.prop modules."
|
|
# Checks if any other modules are using a local copy of build.prop
|
|
BUILDMODULE=false
|
|
MODID=$(get_file_value $MODPATH/module.prop "id=")
|
|
for D in $(ls $IMGPATH); do
|
|
if [ $D != "$MODID" ]; then
|
|
if [ -f "$IMGPATH/$D/system/build.prop" ]; then
|
|
NAME=$(get_file_value $IMGPATH/$D/module.prop "name=")
|
|
log_handler "Conflicting build.prop editing in module '$NAME'."
|
|
BUILDMODULE=true
|
|
fi
|
|
fi
|
|
done
|
|
if [ "$BUILDMODULE" == "true" ]; then
|
|
replace_fn BUILDPROPENB 1 0 $LATEFILE
|
|
else
|
|
replace_fn BUILDPROPENB 0 1 $LATEFILE
|
|
fi
|
|
|
|
# Copies the stock build.prop to the module. Only if set in propsconf_late.
|
|
if [ "$(get_file_value $LATEFILE "BUILDPROPENB=")" == 1 ] && [ "$(get_file_value $LATEFILE "BUILDEDIT=")" == 1 ]; then
|
|
log_handler "Stock build.prop copied from /system."
|
|
cp -af $SYSTEMLOC/build.prop $MODPATH/system/build.prop >> $LOGFILE 2>&1
|
|
|
|
# Edits the module copy of build.prop
|
|
module_values
|
|
log_handler "Editing build.prop."
|
|
# ro.build props
|
|
change_prop_file "build"
|
|
# Fingerprint
|
|
if [ "$MODULEFINGERPRINT" ] && [ "$(get_file_value $LATEFILE "SETFINGERPRINT=")" == "true" ] && [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ]; then
|
|
PRINTSTMP="$(cat $SYSTEMLOC/build.prop | grep "$ORIGFINGERPRINT")"
|
|
for ITEM in $PRINTSTMP; do
|
|
replace_fn $(get_eq_left "$ITEM") $(get_eq_right "$ITEM") $MODULEFINGERPRINT $MODPATH/system/build.prop && log_handler "$(get_eq_left "$ITEM")=$MODULEFINGERPRINT"
|
|
done
|
|
fi
|
|
else
|
|
rm -f $MODPATH/system/build.prop
|
|
log_handler "Build.prop editing disabled."
|
|
fi
|
|
else
|
|
rm -f $MODPATH/system/build.prop
|
|
log_handler "Prop file editing disabled. All values ok."
|
|
fi
|
|
|
|
# Check if the late_start service log file exists.
|
|
if [ -f "$POSTLOGFILE" ]; then
|
|
log_handler "Removing post-fs-data log ($POSTLOGFILE)."
|
|
rm -f $POSTLOGFILE
|
|
fi
|
|
fi
|
|
|
|
log_script_chk "post-fs-data.d finished.\n\n===================="
|
|
fi
|
|
else
|
|
echo "$MODPATH not found." >> $POSTLOGFILE 2>&1
|
|
echo "Module no longer installed." >> $POSTLOGFILE 2>&1
|
|
fi
|