From 27c62203a2df7f0ac48421bba9ca1fa13361ab24 Mon Sep 17 00:00:00 2001 From: Didgeridoohan Date: Sat, 2 Feb 2019 13:37:20 +0100 Subject: [PATCH] v3.0.0-v42 --- README.md | 73 ++- common/post-fs-data.sh | 160 +++++-- common/prints.sh | 5 +- common/propsconf_conf | 86 +++- common/propsconf_late | 201 ++++----- common/service.sh | 67 +++ common/util_functions.sh | 927 ++++++++++++++++++++++++--------------- config.sh | 225 ++++++---- module.prop | 4 +- system/binpath/props | Bin 52710 -> 61209 bytes 10 files changed, 1110 insertions(+), 638 deletions(-) create mode 100644 common/service.sh diff --git a/README.md b/README.md index 6a58c10..175f0bf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Keep reading below to find out more details about the different parts of the mod - [Installation](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#installation) - [Usage](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#usage) - [Spoofing device's fingerprint to pass the ctsProfile check](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#spoofing-devices-fingerprint-to-pass-the-ctsprofile-check) + - [Use vendor fingerprint](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#use-vendor-fingerprint - [Matching the Android security patch date](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf#matching-the-android-security-patch-date) - [Can I use any fingerprint?](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#can-i-use-any-fingerprint) - [Finding a certified fingerprint](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#finding-a-certified-fingerprint) @@ -31,6 +32,7 @@ Keep reading below to find out more details about the different parts of the mod - [Current fingerprints list version](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#current-fingerprints-list-version) - [Please add support for device X](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf/blob/master/README.md#please-add-support-for-device-x) - [Please update fingerprint X](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf/blob/master/README.md#please-update-fingerprint-x) +- [Device simulation](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf/blob/master/README.md#device-simulation) - [Improved root hiding - Editing build.prop and default.prop](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#improved-root-hiding---editing-buildprop-and-defaultprop) - [Set/reset MagiskHide Sensitive props](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#setreset-magiskhide-sensitive-props) - [Change/set custom prop values](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#changeset-custom-prop-values) @@ -40,7 +42,7 @@ Keep reading below to find out more details about the different parts of the mod - [Script colours](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#script-colours) - [Fingerprints list check](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#fingerprints-list-check) - [Configuration file](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#configuration-file) - - [Setting up the module on a clean ROM flash](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#setting-up-the-module-on-a-clean-rom-flash) + - [Setting up the module on a clean Magisk/ROM flash](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#setting-up-the-module-on-a-clean-magiskrom-flash) - [Miscellaneous MagiskHide issues](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#miscellaneous-magiskhide-issues) - [Issues, support,etc](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#issues-support-etc) - [Known issues](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#known-issues) @@ -51,10 +53,12 @@ Keep reading below to find out more details about the different parts of the mod - [Device issues because of the module](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#device-issues-because-of-the-module) - [Logs](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#logs) - [Collecting logs manually](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#collecting-logs-manually) +- [Donations](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#donations) - [Source](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#source) - [Credits](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#credits) - [Changelog](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#changelog) - [Current fingerprints list](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#current-fingerprints-list) +- [Licence](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#mit-licence) ## Prerequisites @@ -79,12 +83,19 @@ If your device can't pass SafetyNet fully, the CTS profile check fails while bas This might be because your device simply hasn't been certified or that the ROM you are using on your device isn't recognised by Google (because it's a custom ROM). -To fix this, you can use a known working fingerprint (one that has been certified by Google), usually from a stock ROM/firmware/factory image, and replace your device's current fingerprint with this. You can also use a fingerprint from another device, but this will change how your device is perceived. +To fix this, you can use a known working device fingerprint (`ro.build.fingerprint`), one that has been certified by Google, usually from a stock ROM/firmware/factory image, and replace your device's current fingerprint with this. You can also use a fingerprint from another device, but this will change how your device is perceived. NOTE: If you're using a fingerprint for an Android build after March 16th 2018 you might have to change the security patch date to one that matches the fingerprint used. You can use the [Custom prop](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#changeset-custom-prop-values) function of this module to change `ro.build.version.security_patch` to the desired date. If you don't know the security patch date you can try finding it with trial and error. The dates are always either the 1st or the 5th of the month, so try different months one after the other until the CTS profile passes. There are a few pre-configured certified fingerprints available in the module, just in case you can't get a hold of one for your device. If you have a working fingerprint that could be added to the list, or an updated one for one already on there, please post that in the [module support thread](https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-t3789228) toghether with device details. Please also include the Android security patch date for the factory image/firmware/ROM that the fingerprint comes from. +After having applied a device fingerprint from the module, whenever that particular print is updated in the included prints list, the chosen fingerprint will be automatically updated when the fingerprints list is. Just reboot to apply the new fingerprint. + +If you are using a Treble GSI ROM you can enable the [Use vendor fingerprint](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#use-vendor-fingerprint-for-treble-gsi-roms) option (for more details, see below) in the `Edit device fingerprint` menu. + +### Use vendor fingerprint (for Treble GSI ROMs) +When using a Treble GSI ROM with a stock vendor partition, it is possible to use the vendor fingerprint to make the device pass the CTS profile check. Enabling this option will make the module scripts pull the vendor fingerprint on each boot and use this to spoof the device fingerprint. This in turn means you will only have to enable this option once and even if you update your vendor partition the fingerprint used will always be the latest one. + ### Matching the Android security patch date For some devices, if the fingerprint is for an Android build after March 16th 2018, it is necessary to use a security patch date that matches the fingerprint used. For the module provided fingerprints this is done automatically, but if you enter a fingerprint manually you will have to update the security patch date yourself (if they don't already match). Use the [Custom props](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#changeset-custom-prop-values) function of this module to change `ro.build.version.security_patch` to the desired date. @@ -156,6 +167,8 @@ The fingerprints list will update without the need to update the entire module. Just run the `props` command and the list will be updated automatically. Use the -nw option to disable or disable it completely in the script settings (see ["Prop script settings"](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config#prop-script-settings) below). If you've disabled the this setting you can update the list manually in the `Edit device fingerprint` menu. +If you already have a device fingerprint set by the module, and it has been updated in the current fingerprints list, it will be automatically updated when the prints list gets an update. Just reboot to apply. + **_Current fingerprints list version - v42_** @@ -173,6 +186,20 @@ If you have an updated fingerprint available (and you've posted it for me to upd You can enter the fingerprint manually in the `Edit device fingerprint` menu in the module, you can use the [configuration file](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf#configuration-file), or you can make a [custom fingerprints list](https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf#custom-fingerprints-list). +## Device simulation +If you want to simulate a specific device (to get access to device specific apps in the Play store, as an example), you can activate this option. It will pull information from the currently used fingerprint (has to be set by the module) and use this to set a few certain props to these values. The props that are set are (currently): +- ro.product.brand +- ro.product.name +- ro.product.device +- ro.build.version.release +- ro.build.id +- ro.build.version.incremental + +By default all props are set when this option is activated, but it is possible to activate and deactivate each prop individually. + +Whenever a fingerprint is set by the module, the `ro.build.description` prop will be set automatically independently from if the general device simulation option is enabled or not. + + ## Improved root hiding - Editing build.prop and default.prop In some rare cases, apps and services look at the actual files (build.prop and default.prop), rather than the set prop values. With this module feature you can make sure that the actual prop in build.prop and default.prop is changed to match whatever value the prop has been set to by either MagiskHide or the module. If there's a prop value set by the module (see ["Set/reset MagiskHide Sensitive props"](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config#setreset-magiskhide-sensitive-props) below), that value takes precedence. @@ -189,12 +216,13 @@ If, for some reason, you need one or more of these to be kept as their original ## Change/set custom prop values -It's quite easy to change prop values with Magisk. With this module it's even easier. Just enter the prop you want to change and the new value and the module does the rest, nice and systemless. Any changes that you've previously done directly to build.prop, default.prop, etc, you can now do with this module instead. +It's quite easy to change prop values with Magisk. With this module it's even easier. Just enter the prop you want to change and the new value and the module does the rest, nice and systemless. Any changes that you've previously done directly to build.prop, default.prop, etc, you can now do with this module instead. If you have a lot of props that you want to change it'll be a lot easier to use the [configuration file](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#configuration-file) (see below). When setting a custom prop you can also pick in what boot stage it should be set in. This can also be changed later for each individual custom prop. There are three options: - Default - The main module option will decide (see [Prop script settings](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#boot-stage) below). - post-fs-data - The prop will always be set in post-fs-data, regardless of the main module option. - late_start service - The prop will always be set in late_start service, regardless of the main module option. +- Both post-fs-data late_start service - In some special cases you would want the prop to be set during both boot stages. An example would be if the system reapplies the stock prop value late in the boot process (after post-fs-data). Note: post-fs-data runs earlier than late_start service. @@ -234,12 +262,16 @@ This option will disable or enable the automatic updating of the fingerprints li ## Configuration file -You can use a configuration file to set your desired options, rather than running the `props` command. Download the [settings file](https://raw.githubusercontent.com/Magisk-Modules-Repo/MagiskHide-Props-Config/master/common/propsconf_conf) or extract it from the module zip (in the common folder), fill in the desired options (follow the instructions in the file), place it in /cache (or /data/cache if you're using an A/B device) and reboot. If you edit the configuration file in Windows, make sure that you use a text editor that can handle [Unix file endings](https://en.m.wikipedia.org/wiki/Newline), such as Notepad++ and similar editors (not regular Notepad). +You can use a configuration file to set your desired options, rather than running the `props` command. This is particularly useful if you have a large amount of custom props you want to set. Download the [settings file](https://raw.githubusercontent.com/Magisk-Modules-Repo/MagiskHide-Props-Config/master/common/propsconf_conf) or extract it from the module zip ('propsconf_conf' in the common folder), fill in the desired options (follow the instructions in the file), place it /data or /cache (or /data/cache if you're using an A/B device) and reboot. You can also use the configuration file when first installing the module. Just place the file in the root of your internal storage (or one of the other previously mentioned locations) before flashing the module and the installation script will set everything up. -This can also be done directly at the first install (through Manager or recovery) and even on a brand new clean install of Magisk, before even rebooting your device. Upon detecting the file, the module boot script will load the configured values and then delete the the configuration file. Instant settings. +If you edit the configuration file in Windows, make sure that you use a text editor that can handle [Unix file endings](https://en.m.wikipedia.org/wiki/Newline), such as Notepad++ and similar editors (not regular Windows Notepad). -### Setting up the module on a clean ROM flash -After having made a clean ROM flash, the configuration file can be used to set the module up as you want without even having to boot first. Just flash the ROM, Magisk and then the module. If you then place a configuration file with your desired settings (fingerprint, custom props, etc) in /cache (or /data/cache if you're using an A/B device), this will be loaded during the first boot. It is possible that this won't work an all device/ROM combinations. If you experience issues, let the ROM boot once before setting everything up. +This can also be done directly at the first install (through Manager or recovery) and even on a brand new clean install of Magisk, before even rebooting your device (also see "Setting up the module on a clean Magisk/ROM flash" below). + +**NOTE!** Upon detecting the file, the module installation/boot script will load the configured values into the module and then delete the the configuration file, so keep a copy somewhere if you want to use the same settings later. + +### Setting up the module on a clean Magisk/ROM flash +After having made a clean ROM flash, the configuration file can be used to set the module up as you want without even having to boot first. First flash the ROM and Magisk. After that you can place the configuration file (see above) with your desired settings (fingerprint, custom props, etc) in the root of your internal storage, /data or /cache (or /data/cache if you're using an A/B device) and then install the module. This will set the module up just as you want it without having to do anything else. It is also possible to place the configuration file after having installed the module and rebooting (although you can only use /data or /cache as a location for the file). This will set everything up during boot, but it is possible that this won't work an all device/ROM combinations. If you experience issues, let the ROM boot once before setting everything up. ## Miscellaneous MagiskHide issues @@ -252,13 +284,15 @@ But first: have you tried turning it off and on again? Toggling MagiskHide off a If you have questions, suggestions or are experiencing some kind of issue, visit the [module support thread](https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-t3789228) @ XDA. ### Known issues +- MagiskHide Props Config v2.7.2 and earlier versions won't work on Magisk v18.1-d73127b1(18006) or later, due to internal changes in Magisk. - Xiaomi devices (MIUI) sometimes have issues passing the ctsProfile check, particularly China releases. Try using [ShellHide](https://forum.xda-developers.com/apps/magisk/magisk-shellhide-t3855616) by @JayminSuthar together with this module. They might work in conjunction to get the device to pass SafetyNet. - If you're on Android Pie you will have to use Magisk v17.2+. Any version prior to that will not be able to change the required prop values. This is because of a change in Android Pie, and with Magisk v17.2 the resetprop tool was been updated for this change. ### An option is marked as "disabled" A couple of the options in the `props` script will be automatically disabled in some circumstances. These are: -- _"Edit device fingerprint"_ will be disabled if another Magisk module that is known to also edit the device fingerprint is installed. Check the logs to get information about which module this is. -- _"Improved hiding"_ will be disable if all relevant prop values already are "safe", or if conflicting modules that also Magic Mounts build.prop are found. +- _"Edit device fingerprint"_ will be disabled if another Magisk module that is known to also edit the device fingerprint is installed. +- _"Device simulation"_ will be disabled if there is no device fingerprint set by the module. +- _"Improved hiding"_ will be disable if all relevant prop values already are "safe" (in other words: the option isn't needed), or if a conflicting module that also Magic Mounts build.prop is found. ### I can't pass the ctsProfile check See ["I still can't pass the ctsProfile check"](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md#i-still-cant-pass-the-ctsprofile-check) above. @@ -293,6 +327,10 @@ The logs will also automatically be saved to the root of the device's internal s If you can't run the `props` script for some reason, the logs are also stored in /cache (or /data/cache for A/B devices). The Magisk log and any files starting with "propsconf" would be useful for troubleshooting (if you don't, or can't, use the "Collect logs" option mentioned above). Providing the output from terminal might also be useful. +## Donations +If you've had any help from me or this module, any kind of [URL="https://forum.xda-developers.com/donatetome.php?u=4667597"]donation[/URL] to support the work involved would of course be appreciated. + + ## Source [GitHub](https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config) @@ -310,6 +348,21 @@ Releases from v2.4.1 are compatible with Magisk v17+. ## Changelog +### v3.0.0 +- New function for device simulation. The module sets a number of device specifying props based on the used fingerprint. See the documentation for details. +- New function for Treble GSI users that have a stock vendor partition: The module can use the certified vendor fingerprint found there. See the documentation for details. Thank you to @oF2pks for making me aware of this possibility. +- New function where the currently used fingerprint automatically will be updated if there's a new fingerprint for that device added to the fingerprints list. See the documentation for details. +- New function to set custom props in both post-fs-data and late_start service mode. See the documentation for details. See the documentation for details. +- Updated the configuration file function so that the file will now be detected during installation or at boot. See the documentation for details. +- Updated the locations for placing the configuration file when importing settings to the module. See the documentation for details. +- Updated the configuration file to be version specific. Make sure you use the latest available configuration file. +- Fixed compatibility with changed boot stages in Magisk v18.1-d73127b1(18006). +- Fixed double download of fingerprints file if using the -f option and cleaned up the runtime options a bit. +- Fixed module reset option. +- Optimised variable and settings retrieval. +- Optimised module boot scripts. +- A whole bunch of minor fixes and cleanups. + ### v2.7.2 - Re-run the post-fs-data script if the Magisk image wasn't mounted yet or if the script has been reset. - Added fingeprints for Razer Phone 1 & 2 and Xiaomi Mi Pad 4, and updated fingerprints for Xiaomi Mi 8, Mi A2 & Pocophone F1. List v40. @@ -664,7 +717,7 @@ Releases from v2.4.1 are compatible with Magisk v17+. ## MIT Licence -*Copyright (c) 2018 Didgeridoohan* +*Copyright (c) 2018-2019 Didgeridoohan* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/common/post-fs-data.sh b/common/post-fs-data.sh index 3ae5a19..e845701 100644 --- a/common/post-fs-data.sh +++ b/common/post-fs-data.sh @@ -7,35 +7,35 @@ MODPATH=${0%/*} # More info in the main Magisk thread # MagiskHide Props Config -# By Didgeridoohan @ XDA Developers - -# Variables -IMGPATH=$(dirname "$MODPATH") -COREPATH=$(dirname "$IMGPATH") -POSTLOGFILE=$CACHELOC/propsconf_postfile.log -POSTDEL=0 +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT # Load functions . $MODPATH/util_functions.sh -if [ ! -f "$POSTCHKFILE" ]; then - touch $POSTCHKFILE +# Variables +IMGPATH=$(dirname "$MODPATH") +COREPATH=$(dirname "$IMGPATH") + +# Start logging +log_start + +# Clears out the script check file +rm -f $RUNFILE +touch $RUNFILE + +# 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 fi -# Check for boot scripts and restore backup if deleted, or if the resetfile is present -if [ ! -f "$POSTFILE" ]; then - # Start logging - log_start - log_handler "post-fs-data boot script not found." - log_handler "Restoring post-fs-data boot script (${POSTFILE})." - cp -af $MODPATH/propsconf_post $POSTFILE >> $LOGFILE 2>&1 - chmod -v 755 $POSTFILE >> $LOGFILE 2>&1 - placeholder_update $POSTFILE COREPATH CORE_PLACEHOLDER "$COREPATH" - placeholder_update $POSTFILE CACHELOC CACHE_PLACEHOLDER "$CACHELOC" - # Deleting settings script to force a restore - rm -f $LATEFILE - POSTDEL=1 -fi +# Check for the boot script and restore backup if deleted, or if the resetfile is present if [ ! -f "$LATEFILE" ] || [ -f "$RESETFILE" ]; then if [ -f "$RESETFILE" ]; then RSTTXT="Resetting" @@ -47,20 +47,118 @@ if [ ! -f "$LATEFILE" ] || [ -f "$RESETFILE" ]; then log_handler "$RSTTXT late_start service boot script (${LATEFILE})." cp -af $MODPATH/propsconf_late $LATEFILE >> $LOGFILE 2>&1 chmod -v 755 $LATEFILE >> $LOGFILE 2>&1 - placeholder_update $LATEFILE POSTFILE POST_PLACEHOLDER "$POSTFILE" placeholder_update $LATEFILE COREPATH CORE_PLACEHOLDER "$COREPATH" placeholder_update $LATEFILE CACHELOC CACHE_PLACEHOLDER "$CACHELOC" fi -# Checking if the post-fs-data boot script ran during boot -if [ -f "$POSTLOGFILE" ] || [ "$POSTDEL" == 1 ]; then - if [ "$(cat $POSTLOGFILE | grep "Module no longer installed.")" ] || [ "$POSTDEL" == 1 ]; then - log_handler "post-fs-data boot script did not run. Attempting a re-run." - . $POSTFILE +# 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 + 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 -log_handler "post-fs-data.sh module script finished.\n\n====================" +# Get default values +log_handler "Checking device default values." +curr_values +# Get the current original values saved in propsconf_late +log_handler "Loading currently saved values." +. $LATEFILE + +# Save default file values in propsconf_late +for ITEM in $VALPROPSLIST; do + TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]') + ORIGPROP="ORIG${TMPPROP}" + ORIGTMP="$(eval "echo \$$ORIGPROP")" + CURRPROP="CURR${TMPPROP}" + CURRTMP="$(eval "echo \$$CURRPROP")" + replace_fn $ORIGPROP "\"$ORIGTMP\"" "\"$CURRTMP\"" $LATEFILE +done +log_handler "Default values saved to $LATEFILE." + +# Check if default file values are safe +orig_safe +# Loading the new values +. $LATEFILE + +# 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 [ "$OPTIONLATE" == 0 ]; then + # ---Setting/Changing fingerprint--- + print_edit + # ---Setting device simulation props--- + dev_sim_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 [ "$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" ] || [ "$D" == "safetypatcher" ]; 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 [ "$BUILDPROPENB" == 1 ] && [ "$BUILDEDIT" == 1 ]; then + log_handler "Stock build.prop copied to module." + cp -af $MIRRORLOC/build.prop $MODPATH/system/build.prop >> $LOGFILE 2>&1 + + # Edits the module copy of build.prop + log_handler "Editing build.prop." + # ro.build props + change_prop_file "build" + # Fingerprint + if [ "$MODULEFINGERPRINT" ] && [ "$SETFINGERPRINT" == "true" ] && [ "$FINGERPRINTENB" == 1 ]; then + PRINTSTMP="$(grep "$ORIGFINGERPRINT" $MIRRORLOC/build.prop)" + for ITEM in $PRINTSTMP; do + replace_fn $(get_eq_left "$ITEM") $(get_eq_right "$ITEM") $(echo $MODULEFINGERPRINT | sed 's|\_\_.*||') $MODPATH/system/build.prop && log_handler "$(get_eq_left "$ITEM")=$(echo $MODULEFINGERPRINT | sed 's|\_\_.*||')" + 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 + +log_script_chk "post-fs-data.sh module script finished.\n\n====================" # Deletes the post-fs-data control file -rm -f $POSTCHKFILE +rm -f $POSTCHKFILE \ No newline at end of file diff --git a/common/prints.sh b/common/prints.sh index 071de39..9b5a27b 100644 --- a/common/prints.sh +++ b/common/prints.sh @@ -1,10 +1,11 @@ #!/system/bin/sh # MagiskHide Props Config -# By Didgeridoohan @ XDA Developers +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT PRINTSV=42 -PRINTSTRANSF=250 +PRINTSTRANSF=260 # Certified fingerprints PRINTSLIST=" diff --git a/common/propsconf_conf b/common/propsconf_conf index f538b8f..72ac491 100644 --- a/common/propsconf_conf +++ b/common/propsconf_conf @@ -1,41 +1,96 @@ #!/system/bin/sh # MagiskHide Props Config -# By Didgeridoohan @ XDA Developers +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT +# Required module version +CONFTRANSF=300 + +# Device fingerprint CONFFINGERPRINT="" +CONFVENDPRINT=false +# Device simulation +CONFDEVSIM=false +CONFBRAND=true +CONFNAME=true +CONFDEVICE=true +CONFRELEASE=true +CONFID=true +CONFINCREMENTAL=true +CONFDESCRIPTION=true + +# Edit prop files CONFPROPFILES=false +# MagiskHide sensitive props CONFDEBUGGABLE="" CONFSECURE="" CONFTYPE="" CONFTAGS="" CONFSELINUX="" +# Set custom props CONFPROPS="" CONFPROPSPOST="" CONFPROPSLATE="" PROPOPTION=replace +# Delete props CONFDELPROPS="" DELPROPOPTION=replace +# Module settings CONFLATE=false -CONFCOLOUR=enabled -CONFWEB=enabled +CONFCOLOUR=true +CONFWEB=true # ================================================================= # ========================== Instructions ========================= # ================================================================= # Set the above variables to the desired prop/configuration values. +# If any variables are left unset, that particular prop/configuration +# will be cleared and the device/Magisk default values will be used. +# If you want to keep any current module settings (for those that +# aren't true/false options), add "preserve" to the variable. +# Example: +# CONFFINGERPRINT=preserve + +# When placed in /cache or the root of your internal storage, the module will load these +# values during boot and the configuration file will be deleted. Keep a backup of the +# file if you want to reuse it at a later time (clean ROM flash, etc). + +# For more information, see the documentation: +# https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md +# and the support thread @ XDA Developers: +# https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-t3789228 + +# ================================================================= +# =========================== Variables =========================== +# ================================================================= # CONFFINGERPRINT should be set to the fingerprint of a ROM that passes # the ctsProfile check. See the prints.sh file for usable prints, # or the documentation for information on how to find one. # Note that Android builds after March 16 2018 often also need to match the Android -# security patch date. Use the CONFPROPS setting to set ro.build.version.security_patch -# to the matching date (example: 2018-10-05). +# security patch date. Add the date to the end of the fingerprint, preceeded by +# two underscores (example: __2018-10-05), or use the CONFPROPS setting +# to set ro.build.version.security_patch to the matching date (example: 2018-10-05). +# +# Changing CONFVENDPRINT to 'true' will enable using the stock vendor +# fingerprint for Treble GSI ROMs (so only us this if you're on a Treble GSI ROM). +# NOTE! Keep in mind that there is no need to enter a fingerprint in +# CONFFINGERPRINT when enabling this option, or setting a security patch date. + +# CONFDEVSIM and the following CONFBRAND, CONFNAME, CONFDEVICE, CONFRELEASE +# CONFID, CONFINCREMENTAL and CONFDESCRIPTION are used to set a number +# of props to simulate a certain deviced based on the fingerprint used. +# CONFDESCRIPTION will automatically be applied if a fingerprint is set +# by the module, but the other props will only be set if CONFDEVSIM is +# set to true, and the default setting for all props are that they will be +# set by the module. If you want to change this, change "true" to "false" +# for the applicable variables. # CONFPROPFILES should be set to "true" if you want to mask the file # values in build.prop and default.prop. For better root hiding. @@ -65,7 +120,7 @@ CONFWEB=enabled # With PROPOPTION you can decide if the current custom prop list should # be replaced, added to or preserved. Add the corresponding words "replace", # "add", or "preserve". The default option is to replace the list. -# This option supersedes the preserve option described below, but only +# This option supersedes the preserve option described above, but only # for the CONFPROPS variables. # CONFDELPROPS is a list of props you want to remove from your system. @@ -82,7 +137,7 @@ CONFWEB=enabled # With DELPROPOPTION you can decide if the current custom prop list should # be replaced, added to or preserved. Add the corresponding words "replace", # "add", or "preserve". The default option is to replace the list. -# This option supersedes the preserve option described below, but only +# This option supersedes the preserve option described above, but only # for the CONFDELPROPS variable. # CONFLATE is by default set to "false". This loads the boot script during the @@ -91,19 +146,4 @@ CONFWEB=enabled # useful if the module's boot script seems to be causing issues during boot. # # CONFCOLOUR and CONFWEB are the options for colour and automatic fingerprints -# list update. See the module documentation for more details. Set to "enabled" or "disabled". - -# If any variables are left unset, that particular prop/configuration -# will be cleared and the device/MagiskHide default values will be used. -# If you want to keep any current module settings, add "preserve" to the variable. -# Example: -# CONFFINGERPRINT=preserve - -# When placed in /cache or the root of your internal storage, the module will load these -# values during boot and the configuration file will be deleted. Keep a backup of the -# file if you want to reuse it at a later time (clean ROM flash, etc). - -# For more information, see the documentation: -# https://github.com/Magisk-Modules-Repo/MagiskHide-Props-Config/blob/master/README.md -# and the support thread @ XDA Developers: -# https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-t3789228 +# list update. See the module documentation for more details. Set to "true" or "false". diff --git a/common/propsconf_late b/common/propsconf_late index 3276cf3..daabfc9 100644 --- a/common/propsconf_late +++ b/common/propsconf_late @@ -1,15 +1,16 @@ #!/system/bin/sh # MagiskHide Props Config -# By Didgeridoohan @ XDA Developers +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT -# This is a script file for the Magisk module "MagiskHide Props Config" By Didgeridoohan @ XDA Developers. +# This is the settings 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 -SCRIPTV=21 +SCRIPTV=22 SETTRANSF=2 NOTTRANSF="OPTIONLATE" @@ -18,11 +19,13 @@ COREPATH=CORE_PLACEHOLDER IMGPATH=$COREPATH/img MODPATH=$IMGPATH/MagiskHidePropsConf CACHELOC=CACHE_PLACEHOLDER -POSTFILE=POST_PLACEHOLDER LATELOGFILE=$CACHELOC/propsconf_latefile.log FINGERPRINTENB=1 +PRINTMODULE=0 PRINTEDIT=0 +PRINTVEND=0 +DEVSIM=0 BUILDPROPENB=1 FILESAFE=1 BUILDEDIT=0 @@ -32,18 +35,89 @@ PROPEDIT=0 CUSTOMEDIT=0 DELEDIT=0 REBOOTCHK=0 +PRINTCHK=0 OPTIONLATE=0 OPTIONCOLOUR=1 OPTIONWEB=1 +OPTIONUPDATE=1 + +BRANDSET=1 +NAMESET=1 +DEVICESET=1 +RELEASESET=1 +IDSET=1 +INCREMENTALSET=1 +DESCRIPTIONSET=1 CACHEFILES=" propsconf_conf reset_mhpc " +# ---Original values--- +# default.prop +ORIGDEBUGGABLE="" +ORIGSECURE="" +# build.prop +ORIGTYPE="" +ORIGTAGS="" +ORIGSELINUX="" +ORIGFINGERPRINT="" +ORIGVENDPRINT="" +ORIGPATCH="" +ORIGBRAND="" +ORIGNAME="" +ORIGDEVICE="" +ORIGRELEASE="" +ORIGID="" +ORIGINCREMENTAL="" +ORIGDESCRIPTION="" + +# ---Module values--- +MODULEDEBUGGABLE="" +MODULESECURE="" +MODULETYPE="" +MODULETAGS="" +MODULESELINUX="" +MODULEFINGERPRINT="" + +# ---Device simulation values--- +SIMBRAND="" +SIMNAME="" +SIMDEVICE="" +SIMRELEASE="" +SIMID="" +SIMINCREMENTAL="" +SIMDESCRIPTION="" + +# ---Custom prop values--- +CUSTOMPROPS="" +CUSTOMPROPSPOST="" +CUSTOMPROPSLATE="" + +# ---Delete prop values--- +DELETEPROPS="" + +# ---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 +SETFINGERPRINT=false + rm -f $LATELOGFILE -# Function to clean up different files after the module has been uninstalled +# Function to clean up some files after the module has been uninstalled cleanup() { echo "Cleaning up files in $CACHELOC." >> $LATELOGFILE 2>&1 for ITEM in $CACHEFILES; do @@ -53,8 +127,7 @@ cleanup() { fi done # Suicide. - echo "Removing scripts." >> $LATELOGFILE 2>&1 - rm -f $POSTFILE >> $LATELOGFILE 2>&1 + echo "Removing script." >> $LATELOGFILE 2>&1 rm -f $0 >> $LATELOGFILE 2>&1 } @@ -65,120 +138,6 @@ if [ -d "$MODPATH" ]; then echo "Module set for removal." >> $LATELOGFILE 2>&1 # Cleanup cleanup - else - # Load functions - . $MODPATH/util_functions.sh - - if [ "$OPTIONLATE" == 0 ]; then - until [ ! -f "$POSTCHKFILE" ]; do - sleep 1 - done - fi - - log_script_chk "Running late_start service boot script." - - if [ -f "$MODPATH/disable" ]; then - log_handler "Module disabled." - else - - # Check the reboot variable - if [ "$(get_file_value $LATEFILE "REBOOTCHK\=")" == 1 ]; then - replace_fn REBOOTCHK 1 0 $LATEFILE - fi - - # ---Original values--- - # default.prop - ORIGDEBUGGABLE="" - ORIGSECURE="" - # build.prop - ORIGTYPE="" - ORIGTAGS="" - ORIGSELINUX="" - ORIGFINGERPRINT="" - ORIGPATCH="" - - # ---Module values--- - MODULEDEBUGGABLE="" - MODULESECURE="" - MODULETYPE="" - MODULETAGS="" - MODULESELINUX="" - MODULEFINGERPRINT="" - - # ---Custom prop values--- - CUSTOMPROPS="" - CUSTOMPROPSPOST="" - CUSTOMPROPSLATE="" - - # ---Delete prop values--- - DELETEPROPS="" - - # ---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 - SETFINGERPRINT=false - - # Edits prop values if set for late_start service - 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" - fi - # 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 - - # ---Edits default.prop--- - if [ "$DEFAULTEDIT" == 1 ] && [ "$FILESAFE" == 0 ]; then - log_handler "Editing default.prop." - mount -wo remount rootfs / - change_prop_file "default" - mount -ro remount rootfs / - else - log_handler "Default.prop editing disabled." - fi - - # Get currently saved values - log_handler "Checking current values." - curr_values - - # 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 - fi - - log_script_chk "late_start service boot script finished.\n\n==================" - fi fi else echo "$MODPATH not found." >> $LATELOGFILE 2>&1 diff --git a/common/service.sh b/common/service.sh new file mode 100644 index 0000000..e821337 --- /dev/null +++ b/common/service.sh @@ -0,0 +1,67 @@ +#!/system/bin/sh +# Please don't hardcode /magisk/modname/... ; instead, please use $MODPATH/... +# This will make your scripts compatible even if Magisk change its mount point in the future +MODPATH=${0%/*} + +# This script will be executed in late_start service mode +# More info in the main Magisk thread + +# MagiskHide Props Config +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT + +# Load functions +. $MODPATH/util_functions.sh + +if [ "$OPTIONLATE" == 0 ]; then + until [ ! -f "$POSTCHKFILE" ]; do + sleep 1 + done +fi + +log_script_chk "Running service.sh module script." + +# Edits prop values if set for late_start service +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 device simulation props--- + dev_sim_edit + # ---Setting custom props--- + custom_edit "CUSTOMPROPS" +fi +# 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 + +# ---Edits default.prop--- +if [ "$DEFAULTEDIT" == 1 ] && [ "$FILESAFE" == 0 ]; then + log_handler "Editing default.prop." + mount -wo remount rootfs / + change_prop_file "default" + mount -ro remount rootfs / +else + log_handler "Default.prop editing disabled." +fi + +# Get currently saved values +log_handler "Checking current values." +curr_values + +log_script_chk "service.sh module script finished.\n\n==================" diff --git a/common/util_functions.sh b/common/util_functions.sh index c8774c5..0b35596 100644 --- a/common/util_functions.sh +++ b/common/util_functions.sh @@ -1,14 +1,14 @@ #!/system/bin/sh # MagiskHide Props Config -# By Didgeridoohan @ XDA Developers +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers +# Licence: MIT -# Variables +# ======================== Variables ======================== MODVERSION=VER_PLACEHOLDER MIRRORPATH=$COREPATH/mirror -POSTFILE=POST_PLACEHOLDER LATEFILE=LATE_PLACEHOLDER -SYSTEMLOC=SYSTEM_PLACEHOLDER +MIRRORLOC=MIRROR_PLACEHOLDER CACHELOC=CACHE_PLACEHOLDER POSTCHKFILE=$CACHELOC/propsconf_postchk RUNFILE=$MODPATH/script_check @@ -24,30 +24,21 @@ $MIRRORPATH/system/build.prop $MIRRORPATH/vendor/build.prop $LATEFILE " -CONFFILE=$CACHELOC/propsconf_conf +CONFFILELST=" +/sdcard/propsconf_conf +/data/propsconf_conf +$CACHELOC/propsconf_conf +" RESETFILE=$CACHELOC/reset_mhpc MAGISKLOC=/data/adb/magisk +# Make sure that the terminal app used actually can see resetprop +alias resetprop="$MAGISKLOC/magisk resetprop" +# Finding installed Busybox if [ -d "$IMGPATH/busybox-ndk" ]; then BBPATH=$(find $IMGPATH/busybox-ndk -name 'busybox') else BBPATH=$(which busybox) fi -alias cat="$BBPATH cat" -alias chmod="$BBPATH chmod" -alias cp="$BBPATH cp" -alias grep="$BBPATH grep" -alias id="$BBPATH id" -alias mv="$BBPATH mv" -alias printf="$BBPATH printf" -alias sed="$BBPATH sed" -alias sort="$BBPATH sort" -alias tar="$BBPATH tar" -alias tee="$BBPATH tee" -alias tr="$BBPATH tr" -alias wget="$BBPATH wget" -if [ -z "$(echo $PATH | grep /sbin:)" ]; then - alias resetprop="$MAGISKLOC/magisk resetprop" -fi PRINTSLOC=$MODPATH/prints.sh PRINTSTMP=$CACHELOC/prints.sh PRINTSWWW="https://raw.githubusercontent.com/Magisk-Modules-Repo/MagiskHide-Props-Config/master/common/prints.sh" @@ -76,22 +67,46 @@ ro.build.tags=release-keys ro.build.selinux=0 " -# Print props +# Fingerprint props to change PRINTPROPS=" ro.build.fingerprint ro.bootimage.build.fingerprint ro.vendor.build.fingerprint " +# Print parts +PRINTPARTS=" +ro.product.brand +ro.product.name +ro.product.device +ro.build.version.release +ro.build.id +ro.build.version.incremental +" + # Additional SafetyNet props SNPROPS=" ro.build.version.security_patch " +# Additional props +ADNPROPS=" +ro.build.fingerprint +ro.vendor.build.fingerprint +ro.build.description +" + +# Values props list +VALPROPSLIST=$PROPSLIST$PRINTPARTS$SNPROPS$ADNPROPS + +# Loading module settings +. $LATEFILE + +# ======================== General functions ======================== # Finding file values get_file_value() { if [ -f "$1" ]; then - cat $1 | grep $2 | sed "s|.*${2}||" | sed 's|\"||g' + grep $2 $1 | sed "s|.*${2}||" | sed 's|\"||g' fi } @@ -111,7 +126,7 @@ log_start() { log_handler() { if [ "$(id -u)" == 0 ] ; then echo "" >> $LOGFILE 2>&1 - echo -e "$(date +"%m-%d-%Y %H:%M:%S") - $1" >> $LOGFILE 2>&1 + echo -e "$(date +"%Y-%m-%d %H:%M:%S:%N") - $1" >> $LOGFILE 2>&1 fi } log_print() { @@ -145,22 +160,32 @@ menu_header() { echo $DIVIDER } +# Get module version +module_v_ctrl() { + VERSIONTMP=$(get_file_value $MODPATH/module.prop "version=") + VERSIONCMP=$(echo $VERSIONTMP | sed 's|v||g' | sed 's|-.*||' | sed 's|\.||g') +} + # Find prop type get_prop_type() { - echo $1 | sed 's|.*\.||' + if [ "$1" == "ro.vendor.build.fingerprint" ]; then + echo "vendprint" + else + echo $1 | sed 's|.*\.||' | sed 's|.*\_||' + fi } # Get left side of = get_eq_left() { - echo $1 | sed 's|=.*||' + echo $1 | cut -f 1 -d '=' } # Get right side of = get_eq_right() { - echo $1 | sed 's|.*=||' + echo $1 | cut -f 2 -d '=' } -# Get first word in string +# Get first word in fingerprint string get_first() { case $1 in *\ *) echo $1 | sed 's|\ .*||' @@ -185,9 +210,10 @@ get_device_used() { fi } -# Get Android version for current fingerprint +# Get Android version with 3 digits for current fingerprint get_android_version() { - VERTMP="$(echo $1 | sed 's|:user.*||' | sed 's|.*:||' | sed 's|/.*||' | sed 's|\.||g')" + print_parts $1 "var" + VERTMP=$VARRELEASE if [ "${#VERTMP}" -lt 3 ]; then until [ "${#VERTMP}" == 3 ] do @@ -212,7 +238,7 @@ replace_fn() { sed -i "s|${1}=${2}|${1}=${3}|" $4 } -# Format user files +# Format user files to remove Windows file endings format_file() { log_handler "Formating file (${1})." # Remove Windows line endings @@ -234,136 +260,45 @@ placeholder_update() { esac } +# Check if boot scripts ran during boot +script_ran_check() { + POSTCHECK=0 + if [ -f "$RUNFILE" ] && [ "$(grep "post-fs-data.sh module script finished" $RUNFILE)" ]; then + POSTCHECK=1 + fi + LATECHECK=0 + if [ -f "$RUNFILE" ] && [ "$(grep "service.sh module script finished" $RUNFILE)" ]; then + LATECHECK=1 + fi +} + # Check for original prop values orig_check() { - PROPSTMPLIST=$PROPSLIST" - ro.build.fingerprint - " + PROPSTMPLIST=$VALPROPSLIST ORIGLOAD=0 for PROPTYPE in $PROPSTMPLIST; do PROP=$(get_prop_type $PROPTYPE) ORIGPROP=$(echo "ORIG${PROP}" | tr '[:lower:]' '[:upper:]') - ORIGVALUE=$(get_file_value $LATEFILE "${ORIGPROP}=") + ORIGVALUE="$(echo ${ORIGPROP})" if [ "$ORIGVALUE" ]; then ORIGLOAD=1 fi done } -# Check if boot scripts ran during boot -script_ran_check() { - POSTCHECK=0 - if [ -f "$RUNFILE" ] && [ "$(cat $RUNFILE | grep "post-fs-data boot script finished")" ]; then - POSTCHECK=1 - fi - LATECHECK=0 - if [ -f "$RUNFILE" ] && [ "$(cat $RUNFILE | grep "late_start service boot script finished")" ]; then - LATECHECK=1 - fi -} - # Load currently set values curr_values() { - CURRDEBUGGABLE=$(resetprop -v ro.debuggable) >> $LOGFILE 2>&1 - CURRSECURE=$(resetprop -v ro.secure) >> $LOGFILE 2>&1 - CURRTYPE=$(resetprop -v ro.build.type) >> $LOGFILE 2>&1 - CURRTAGS=$(resetprop -v ro.build.tags) >> $LOGFILE 2>&1 - CURRSELINUX=$(resetprop -v ro.build.selinux) >> $LOGFILE 2>&1 - CURRFINGERPRINT=$(resetprop -v ro.build.fingerprint) >> $LOGFILE 2>&1 + for ITEM in $VALPROPSLIST; do + CURRTMP=$(resetprop -v $ITEM) >> $LOGFILE 2>&1 + TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]') + eval "CURR${TMPPROP}='$CURRTMP'" + done if [ -z "$CURRFINGERPRINT" ]; then CURRFINGERPRINT=$(resetprop -v ro.bootimage.build.fingerprint) >> $LOGFILE 2>&1 if [ -z "$CURRFINGERPRINT" ]; then CURRFINGERPRINT=$(resetprop -v ro.vendor.build.fingerprint) >> $LOGFILE 2>&1 fi fi - CURRPATCH=$(resetprop -v ro.build.version.security_patch) >> $LOGFILE 2>&1 -} - -# Load original values -orig_values() { - ORIGDEBUGGABLE=$(get_file_value $LATEFILE "ORIGDEBUGGABLE=") - ORIGSECURE=$(get_file_value $LATEFILE "ORIGSECURE=") - ORIGTYPE=$(get_file_value $LATEFILE "ORIGTYPE=") - ORIGTAGS=$(get_file_value $LATEFILE "ORIGTAGS=") - ORIGSELINUX=$(get_file_value $LATEFILE "ORIGSELINUX=") - ORIGFINGERPRINT=$(get_file_value $LATEFILE "ORIGFINGERPRINT=") - ORIGPATCH=$(get_file_value $LATEFILE "ORIGPATCH=") -} - -# Load module values -module_values() { - MODULEDEBUGGABLE=$(get_file_value $LATEFILE "MODULEDEBUGGABLE=") - MODULESECURE=$(get_file_value $LATEFILE "MODULESECURE=") - MODULETYPE=$(get_file_value $LATEFILE "MODULETYPE=") - MODULETAGS=$(get_file_value $LATEFILE "MODULETAGS=") - MODULESELINUX=$(get_file_value $LATEFILE "MODULESELINUX=") - MODULEFINGERPRINT=$(get_file_value $LATEFILE "MODULEFINGERPRINT=") - CUSTOMPROPS=$(get_file_value $LATEFILE "CUSTOMPROPS=") - CUSTOMPROPSPOST=$(get_file_value $LATEFILE "CUSTOMPROPSPOST=") - CUSTOMPROPSLATE=$(get_file_value $LATEFILE "CUSTOMPROPSLATE=") - CUSTOMPROPSLIST="$CUSTOMPROPS $CUSTOMPROPSPOST $CUSTOMPROPSLATE" - DELETEPROPS=$(get_file_value $LATEFILE "DELETEPROPS=") -} - -# Run all value loading functions -all_values() { - log_handler "Loading values." - # Currently set values - curr_values - # Original values - orig_values - # Module values - module_values -} - -# Run after updated props/settings -after_change() { - # Update the reboot variable - reboot_chk - # Load all values - all_values - # Ask to reboot - reboot_fn "$1" -} - -# Run after changing props/settings with configuration file -after_change_file() { - # Update the reboot variable - reboot_chk - # Load all values - INPUT="" - all_values - # Ask to reboot - reboot_fn "$1" "$2" -} - -# Check if module needs a reboot -reboot_chk() { - replace_fn REBOOTCHK 0 1 $LATEFILE -} - -# Reset module -reset_fn() { - BUILDPROPENB=$(get_file_value $LATEFILE "BUILDPROPENB=") - FINGERPRINTENB=$(get_file_value $LATEFILE "FINGERPRINTENB=") - cp -af $MODPATH/propsconf_late $LATEFILE >> $LOGFILE 2>&1 - if [ "$BUILDPROPENB" ] && [ "$BUILDPROPENB" != 1 ]; then - replace_fn BUILDPROPENB 1 $BUILDPROPENB $LATEFILE - fi - if [ "$FINGERPRINTENB" ] && [ "$FINGERPRINTENB" != 1 ]; then - replace_fn FINGERPRINTENB 1 $FINGERPRINTENB $LATEFILE - fi - chmod -v 755 $LATEFILE >> $LOGFILE 2>&1 - placeholder_update $LATEFILE IMGPATH IMG_PLACEHOLDER $IMGPATH - placeholder_update $LATEFILE CACHELOC CACHE_PLACEHOLDER $CACHELOC - - if [ "$1" != "post" ]; then - # Update the reboot variable - reboot_chk - - # Update all prop value variables - all_values - fi } # Check if original file values are safe @@ -388,127 +323,227 @@ orig_safe() { done } +# Run all value loading functions +all_values() { + log_handler "Loading values." + # Currently set values + curr_values + # Module saved values + . $LATEFILE +} + +# Run after updated props/settings +after_change() { + if [ "$2" == "file" ]; then + # Load module settings + . $LATEFILE + else + # Update the reboot variable + reboot_chk + # Load all values + all_values + # Ask to reboot + reboot_fn "$1" "$2" + fi +} + +# Run after changing props/settings with configuration file +after_change_file() { + # Update the reboot variable + reboot_chk + # Load all values + INPUT="" + all_values + # Ask to reboot + reboot_fn "$1" "$2" +} + +# Check if module needs a reboot +reboot_chk() { + replace_fn REBOOTCHK 0 1 $LATEFILE +} + +# Reset module +reset_fn() { + cp -af $MODPATH/propsconf_late $LATEFILE >> $LOGFILE 2>&1 + if [ "$BUILDPROPENB" ] && [ "$BUILDPROPENB" != 1 ]; then + replace_fn BUILDPROPENB 1 $BUILDPROPENB $LATEFILE + fi + if [ "$FINGERPRINTENB" ] && [ "$FINGERPRINTENB" != 1 ]; then + replace_fn FINGERPRINTENB 1 $FINGERPRINTENB $LATEFILE + fi + chmod -v 755 $LATEFILE >> $LOGFILE 2>&1 + placeholder_update $LATEFILE CACHELOC CACHE_PLACEHOLDER "$CACHELOC" + placeholder_update $LATEFILE COREPATH CORE_PLACEHOLDER "$COREPATH" + + if [ "$1" != "post" ]; then + # Update the reboot variable + reboot_chk + # Update all prop value variables + all_values + fi +} + # Checks for configuration file config_file() { log_handler "Checking for configuration file." - if [ -s "$CONFFILE" ]; then + CONFFILE="" + for ITEM in $CONFFILELST; do + if [ -s "$ITEM" ]; then + CONFFILE="$ITEM" + break + fi + done + if [ "$CONFFILE" ]; then log_handler "Configuration file detected (${CONFFILE})." format_file $CONFFILE # Loads custom variables . $CONFFILE - # Updates prop values (including fingerprint) - PROPSTMPLIST=$PROPSLIST" - ro.build.fingerprint - " - for PROPTYPE in $PROPSTMPLIST; do - CONFPROP=$(echo "CONF$(get_prop_type $PROPTYPE)" | tr '[:lower:]' '[:upper:]') - TMPPROP=$(eval "echo \$$CONFPROP") - if [ "$TMPPROP" ]; then - log_handler "Checking $PROPTYPE settings." - if [ "$TMPPROP" != "preserve" ]; then - if [ "$PROPTYPE" == "ro.build.fingerprint" ]; then - if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ]; then - change_print "$PROPTYPE" "$TMPPROP" "file" + module_v_ctrl + if [ "$CONFTRANSF" -le $VERSIONCMP ]; then + # Check if vendor fingerprint is set + if [ "$CONFVENDPRINT" == "true" ]; then + log_handler "Using vendor fingerprint" + CONFFINGERPRINT=$(resetprop -v ro.vendor.build.fingerprint) >> $LOGFILE 2>&1 + fi + # Updates prop values (including fingerprint) + PROPSTMPLIST=$PROPSLIST" + ro.build.fingerprint + " + for PROPTYPE in $PROPSTMPLIST; do + CONFPROP=$(echo "CONF$(get_prop_type $PROPTYPE)" | tr '[:lower:]' '[:upper:]') + TMPPROP=$(eval "echo \$$CONFPROP") + if [ "$TMPPROP" ]; then + log_handler "Checking $PROPTYPE settings." + if [ "$TMPPROP" != "preserve" ]; then + if [ "$PROPTYPE" == "ro.build.fingerprint" ]; then + if [ "$FINGERPRINTENB" == 1 ]; then + change_print "$PROPTYPE" "$TMPPROP" "file" + fi + else + change_prop "$PROPTYPE" "$TMPPROP" "file" fi - else - change_prop "$PROPTYPE" "$TMPPROP" "file" - fi - fi - else - if [ "$PROPTYPE" == "ro.build.fingerprint" ]; then - if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ]; then - reset_print "$PROPTYPE" "file" fi else - reset_prop "$PROPTYPE" "file" - fi - fi - done - - # Updates prop file editing - if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then - if [ "$CONFPROPFILES" == "true" ]; then - edit_prop_files "file" "" " (configuration file)" - elif [ "$CONFPROPFILES" == "false" ]; then - reset_prop_files "file" "" " (configuration file)" - fi - fi - - # Updates custom props - if [ "$PROPOPTION" != "preserve" ]; then - if [ "$CONFPROPS" ] || [ "$CONFPROPSPOST" ] || [ "$CONFPROPSLATE" ]; then - if [ "$PROPOPTION" == "add" ] || [ "$PROPOPTION" == "replace" ]; then - if [ "$PROPOPTION" == "replace" ]; then - reset_all_custprop "file" - fi - if [ "$CONFPROPS" ]; then - for ITEM in $CONFPROPS; do - set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "default" "file" - done - fi - if [ "$CONFPROPSPOST" ]; then - for ITEM in $CONFPROPSPOST; do - set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "post" "file" - done - fi - if [ "$CONFPROPSLATE" ]; then - for ITEM in $CONFPROPSLATE; do - set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "late" "file" - done + if [ "$PROPTYPE" == "ro.build.fingerprint" ]; then + if [ "$FINGERPRINTENB" == 1 ]; then + reset_print "$PROPTYPE" "file" + fi + else + reset_prop "$PROPTYPE" "file" fi fi - else - reset_all_custprop "file" - fi - fi + done - # Updates props to delete - if [ "$DELPROPOPTION" != "preserve" ]; then - if [ "$CONFDELPROPS" ]; then - if [ "$DELPROPOPTION" == "add" ] || [ "$DELPROPOPTION" == "replace" ]; then - if [ "$DELPROPOPTION" == "replace" ]; then - reset_all_delprop "file" - fi - for ITEM in $CONFDELPROPS; do - set_delprop "$ITEM" "file" + # Updates device simulation options, only if fingerprint editing is enabled + if [ "$PRINTEDIT" == 1 ]; then + # Fingerprint parts + if [ "$CONFDEVSIM" == "true" ]; then + change_dev_sim "Device simulation" "file" + for ITEM in $PRINTPARTS; do + TMPVAR="CONF$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]')" + if [ $(eval "echo \$$TMPVAR") == "true" ]; then + TMPVAL=1 + else + TMPVAL=0 + fi + change_sim_prop "Device simulation" "$ITEM" "$TMPVAL" "file" done fi - else - reset_all_delprop "file" + # Device description + if [ "$CONFDESCRIPTION" == "true" ]; then + change_sim_descr "Device simulation" 1 "file" + else + change_sim_descr "Device simulation" 0 "file" + fi fi - fi - # Updates options - OPTLCURR=$(get_file_value $LATEFILE "OPTIONLATE=") - OPTCCURR=$(get_file_value $LATEFILE "OPTIONCOLOUR=") - OPTWCURR=$(get_file_value $LATEFILE "OPTIONWEB=") - if [ "$CONFLATE" == "true" ]; then - OPTLCHNG=1 - TMPTXT="late_start service" + # Updates prop file editing + if [ "$FILESAFE" == 0 ]; then + if [ "$CONFPROPFILES" == "true" ]; then + edit_prop_files "file" "" " (configuration file)" + elif [ "$CONFPROPFILES" == "false" ]; then + reset_prop_files "file" "" " (configuration file)" + fi + fi + + # Updates custom props + if [ "$PROPOPTION" != "preserve" ]; then + if [ "$CONFPROPS" ] || [ "$CONFPROPSPOST" ] || [ "$CONFPROPSLATE" ]; then + if [ "$PROPOPTION" == "add" ] || [ "$PROPOPTION" == "replace" ]; then + if [ "$PROPOPTION" == "replace" ]; then + reset_all_custprop "file" + fi + if [ "$CONFPROPS" ]; then + for ITEM in $CONFPROPS; do + set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "default" "file" + done + fi + if [ "$CONFPROPSPOST" ]; then + for ITEM in $CONFPROPSPOST; do + set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "post" "file" + done + fi + if [ "$CONFPROPSLATE" ]; then + for ITEM in $CONFPROPSLATE; do + set_custprop "$(get_eq_left "$ITEM")" "$(get_eq_right "$ITEM")" "late" "file" + done + fi + fi + else + reset_all_custprop "file" + fi + fi + + # Updates props to delete + if [ "$DELPROPOPTION" != "preserve" ]; then + if [ "$CONFDELPROPS" ]; then + if [ "$DELPROPOPTION" == "add" ] || [ "$DELPROPOPTION" == "replace" ]; then + if [ "$DELPROPOPTION" == "replace" ]; then + reset_all_delprop "file" + fi + for ITEM in $CONFDELPROPS; do + set_delprop "$ITEM" "file" + done + fi + else + reset_all_delprop "file" + fi + fi + + # Updates options + if [ "$CONFLATE" == "true" ]; then + OPTLCHNG=1 + TMPTXT="late_start service" + else + OPTLCHNG=0 + TMPTXT="post-fs-data" + fi + replace_fn OPTIONLATE $OPTIONLATE $OPTLCHNG $LATEFILE + log_handler "Boot stage is ${TMPTXT}." + if [ "$CONFCOLOUR" == "true" ]; then + OPTCCHNG=1 + else + OPTCCHNG=0 + fi + replace_fn OPTIONCOLOUR $OPTIONCOLOUR $OPTCCHNG $LATEFILE + log_handler "Colour $CONFCOLOUR." + if [ "$CONFWEB" == "true" ]; then + OPTWCHNG=1 + else + OPTWCHNG=0 + fi + replace_fn OPTIONWEB $OPTIONWEB $OPTWCHNG $LATEFILE + log_handler "Automatic fingerprints list update $CONFWEB." else - OPTLCHNG=0 - TMPTXT="post-fs-data" + log_handler "The configuration file is not compatible with the current module version." fi - replace_fn OPTIONLATE $OPTLCURR $OPTLCHNG $LATEFILE - log_handler "Boot stage is ${TMPTXT}." - if [ "$CONFCOLOUR" == "enabled" ]; then - OPTCCHNG=1 - else - OPTCCHNG=0 - fi - replace_fn OPTIONCOLOUR $OPTCCURR $OPTCCHNG $LATEFILE - log_handler "Colour $CONFCOLOUR." - if [ "$CONFWEB" == "enabled" ]; then - OPTWCHNG=1 - else - OPTWCHNG=0 - fi - replace_fn OPTIONWEB $OPTWCURR $OPTWCHNG $LATEFILE - log_handler "Automatic fingerprints list update $CONFWEB." # Deletes the configuration file log_handler "Deleting configuration file." rm -f $CONFFILE + log_handler "Configuration file import complete." + else log_handler "No configuration file." fi @@ -522,25 +557,44 @@ test_connection() { # ======================== Fingerprint functions ======================== # Set new fingerprint print_edit() { - if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 -o "$(get_file_value $LATEFILE "PRINTMODULE=")" == "false" ] && [ "$(get_file_value $LATEFILE "PRINTEDIT=")" == 1 ]; then + if [ "$FINGERPRINTENB" == 1 -o "$PRINTMODULE" == 0 ] && [ "$PRINTEDIT" == 1 ]; then log_handler "Changing fingerprint." - PRINTCHNG="$(get_file_value $LATEFILE "MODULEFINGERPRINT=" | sed 's|\_\_.*||')" + if [ "$PRINTVEND" == 1 ]; then + log_handler "Using vendor fingerprint (for Treble GSI ROMs)." + PRINTCHNG="$(resetprop ro.vendor.build.fingerprint)" + # Set device simulation variables + print_parts "$PRINTCHNG" + else + PRINTCHNG="$(echo $MODULEFINGERPRINT | sed 's|\_\_.*||')" + fi for ITEM in $PRINTPROPS; do log_handler "Changing/writing $ITEM." resetprop -v $ITEM >> $LOGFILE 2>&1 resetprop -nv $ITEM $PRINTCHNG >> $LOGFILE 2>&1 done # Edit security patch date if included - SECPATCH="$(get_sec_patch $(get_file_value $LATEFILE "MODULEFINGERPRINT="))" - case "$(get_file_value $LATEFILE "MODULEFINGERPRINT=")" in - *__*) - if [ "$SECPATCH" ]; then - log_handler "Update security patch date to match fingerprint used." - resetprop -v ro.build.version.security_patch >> $LOGFILE 2>&1 - resetprop -v ro.build.version.security_patch $SECPATCH >> $LOGFILE 2>&1 - fi - ;; - esac + if [ "$PRINTVEND" != 1 ]; then + SECPATCH="$(get_sec_patch $MODULEFINGERPRINT)" + case "$MODULEFINGERPRINT" in + *__*) + if [ "$SECPATCH" ]; then + log_handler "Updating security patch date to match fingerprint used." + resetprop -v ro.build.version.security_patch >> $LOGFILE 2>&1 + resetprop -nv ro.build.version.security_patch $SECPATCH >> $LOGFILE 2>&1 + fi + ;; + esac + fi + # Edit device description + if [ "$DESCRIPTIONSET" == 1 ]; then + if [ "$SIMDESCRIPTION" ]; then + log_handler "Changing/writing ro.build.description." + resetprop -v ro.build.description >> $LOGFILE 2>&1 + resetprop -nv ro.build.description "$SIMDESCRIPTION" >> $LOGFILE 2>&1 + fi + else + log_handler "Changing/writing ro.build.description is disabled." + fi fi } @@ -565,9 +619,39 @@ print_files() { log_handler "Creating files." for OEM in $OEMLIST; do echo -e "PRINTSLIST=\"" >> $PRINTFILES/${OEM}\.sh - cat $PRINTSLOC | grep $OEM >> $PRINTFILES/${OEM}\.sh + grep $OEM >> $PRINTFILES/${OEM}\.sh $PRINTSLOC echo -e "\"" >> $PRINTFILES/${OEM}\.sh done + # Check for updated fingerprint + device_print_update "Updating module fingerprint." +} + +device_print_update() { + if [ "$OPTIONUPDATE" == 1 ]; then + if [ "$FINGERPRINTENB" == 1 -o "$PRINTMODULE" == 0 ] && [ "$PRINTEDIT" == 1 ] && [ "$MODULEFINGERPRINT" ]; then + TMPDEV="${SIMBRAND}/${SIMNAME}/${SIMDEVICE}" + for ITEM in $PRINTSLIST; do + case $ITEM in + *$TMPDEV*) + TMPPRINT=$ITEM + break + ;; + esac + done + log_handler "Checking for updated fingerprint ($TMPDEV)." + if [ "$TMPDEV" ] && [ "$TMPPRINT" ]; then + if [ "$MODULEFINGERPRINT" != "$(get_eq_right $TMPPRINT))" ]; then + log_handler "$1" + change_print "$1" $(get_eq_right $TMPPRINT) "update" + replace_fn PRINTCHK 0 1 $LATEFILE + # Load module values + . $LATEFILE + else + log_handler "No update available." + fi + fi + fi + fi } # Checks and updates the prints list @@ -591,8 +675,7 @@ download_prints() { LISTVERSION=$(get_file_value $PRINTSTMP "PRINTSV=") if [ "$LISTVERSION" ]; then if [ "$LISTVERSION" == "Dev" ] || [ "$LISTVERSION" -gt "$(get_file_value $PRINTSLOC "PRINTSV=")" ]; then - VERSIONTMP=$(get_file_value $MODPATH/module.prop "version=") - VERSIONCMP=$(echo $VERSIONTMP | sed 's|v||g' | sed 's|-.*||' | sed 's|\.||g') + module_v_ctrl if [ "$(get_file_value $PRINTSTMP "PRINTSTRANSF=")" -le $VERSIONCMP ]; then mv -f $PRINTSTMP $PRINTSLOC >> $LOGFILE 2>&1 # Updates list version in module.prop @@ -633,44 +716,187 @@ download_prints() { reset_print() { log_handler "Resetting device fingerprint to default system value." - SUBA=$(get_file_value $LATEFILE "MODULEFINGERPRINT=") - - # Saves new module value - replace_fn MODULEFINGERPRINT "\"$SUBA\"" "\"\"" $LATEFILE + # Saves new module valueS + replace_fn MODULEFINGERPRINT "\"$MODULEFINGERPRINT\"" "\"\"" $LATEFILE + # Updates vendor print setting + replace_fn PRINTVEND 1 0 $LATEFILE # Updates prop change variables in propsconf_late replace_fn PRINTEDIT 1 0 $LATEFILE # Updates improved hiding setting - if [ "$(get_file_value $LATEFILE "BUILDEDIT=")" ]; then - replace_fn SETFINGERPRINT "true" "false" $LATEFILE - fi + replace_fn SETFINGERPRINT "true" "false" $LATEFILE + # Updates simulation setting + replace_fn DEVSIM 1 0 $LATEFILE - if [ "$2" != "file" ]; then - after_change "$1" - fi + # Clear out device simulation variables + print_parts "none" + + after_change "$1" "$2" } # Use fingerprint change_print() { log_handler "Changing device fingerprint to $2." - SUBA=$(get_file_value $LATEFILE "MODULEFINGERPRINT=") - - # Saves new module value - replace_fn MODULEFINGERPRINT "\"$SUBA\"" "\"$2\"" $LATEFILE + # Saves new module values + replace_fn MODULEFINGERPRINT "\"$MODULEFINGERPRINT\"" "\"$2\"" $LATEFILE + # Updates prop change variables in propsconf_late replace_fn PRINTEDIT 0 1 $LATEFILE # Updates improved hiding setting - if [ "$(get_file_value $LATEFILE "BUILDEDIT=")" ]; then - replace_fn SETFINGERPRINT "false" "true" $LATEFILE - fi + replace_fn SETFINGERPRINT "false" "true" $LATEFILE + + # Set device simulation variables + print_parts "$2" NEWFINGERPRINT="" - if [ "$3" != "file" ]; then - after_change "$1" + if [ "$DEVSIM" == 1 ]; then + after_change "$1" "$3" fi } +# Use vendor fingerprint +change_print_vendor() { + if [ $2 == 1 ]; then + STATETXT="Enabling" + TMPVAL=0 + BUILD1="false" + BUILD2="true" + else + STATETXT="Disabling" + TMPVAL=1 + BUILD1="true" + BUILD2="false" + fi + + log_handler "$STATETXT using the stock vendor fingerprint (for Treble GSI ROMs)." + + # Enables or disables the setting + replace_fn PRINTVEND $TMPVAL $2 $LATEFILE + # Updates prop change variables in propsconf_late + replace_fn PRINTEDIT $TMPVAL $2 $LATEFILE + # Clearing out module value + replace_fn MODULEFINGERPRINT "\"$MODULEFINGERPRINT\"" "\"\"" $LATEFILE + # Updates improved hiding setting + replace_fn SETFINGERPRINT $BUILD1 $BUILD2 $LATEFILE + # Updates simulation setting + replace_fn DEVSIM $TMPVAL $2 $LATEFILE + + # Set device simulation variables + print_parts "$ORIGVENDPRINT" + + if [ "$DEVSIM" == 1 ]; then + after_change "$1" "$3" + fi +} + +# Save props values from fingerprint parts +print_parts() { + DLIM1=1 + DLIM2=1 + for ITEM in $PRINTPARTS; do + TMPVALUE="" + TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]') + if [ $1 != "none" ]; then + TMPVALUE=$(echo $1 | sed 's|\:user\/release-keys||' | cut -f $DLIM1 -d ':' | cut -f $DLIM2 -d '/') + eval "VAR${TMPPROP}='$TMPVALUE'" + fi + DLIM2=$(($DLIM2 + 1)) + if [ "$DLIM2" == 4 ]; then + DLIM1=2 + DLIM2=1 + fi + if [ "$2" != "var" ]; then + SUBA=$(get_file_value $LATEFILE "SIM${TMPPROP}=") + replace_fn "SIM${TMPPROP}" "\"$SUBA\"" "\"$TMPVALUE\"" $LATEFILE + fi + done + + VARDESCRIPTION="" + if [ $1 != "none" ]; then + VARDESCRIPTION="${VARNAME}-user $VARRELEASE $VARID $VARINCREMENTAL release-keys" + fi + if [ "$2" != "var" ]; then + replace_fn SIMDESCRIPTION "\"$SIMDESCRIPTION\"" "\"$VARDESCRIPTION\"" $LATEFILE + fi + # Load module values + . $LATEFILE +} + +# ======================== Device simulation functions ======================== +# Edit the simulation props +dev_sim_edit() { + if [ "$FINGERPRINTENB" == 1 -o "$PRINTMODULE" == 0 ] && [ "$PRINTEDIT" == 1 ]; then + if [ "$DEVSIM" == 1 ]; then + log_handler "Editing device simulation props." + for ITEM in $PRINTPARTS; do + TMPPROP=$(get_prop_type $ITEM | tr '[:lower:]' '[:upper:]') + TMPENB=$(get_file_value $LATEFILE "${TMPPROP}SET=") + TMPVALUE=$(get_file_value $LATEFILE "SIM${TMPPROP}=") + if [ "$TMPENB" == 1 ] && [ "$TMPVALUE" ]; then + log_handler "Changing/writing $ITEM." + resetprop -v $ITEM >> $LOGFILE 2>&1 + resetprop -nv $ITEM $TMPVALUE >> $LOGFILE 2>&1 + else + log_handler "Changing/writing $ITEM is disabled." + fi + done + fi + fi + +} + +# Enable/disable the option +change_dev_sim() { + if [ $DEVSIM == 0 ]; then + STATETXT="Enabling" + TMPVAL=1 + else + STATETXT="Disabling" + TMPVAL=0 + fi + + log_handler "$STATETXT basic device simulation." + + # Enables or disables the setting + replace_fn "DEVSIM" $DEVSIM $TMPVAL $LATEFILE + + after_change "$1" "$2" +} + +# Change if prop should be simulated or not +change_sim_prop() { + if [ $3 == 1 ]; then + STATETXT="enabled" + else + STATETXT="disabled" + fi + log_handler "Changing device simulation prop $2 to $STATETXT." + + TMPPROP=$(get_prop_type $2 | tr '[:lower:]' '[:upper:]') + SUBA=$(get_file_value $LATEFILE "${TMPPROP}SET=") + + # Saves new value + replace_fn "${TMPPROP}SET" $SUBA $3 $LATEFILE + + after_change "$1" "$4" +} + +# Change if description should be simulated or not +change_sim_descr() { + if [ $2 == 1 ]; then + STATETXT="enabled" + else + STATETXT="disabled" + fi + log_handler "Changing device description editing to $STATETXT." + + # Saves new value + replace_fn DESCRIPTIONSET $DESCRIPTIONSET $2 $LATEFILE + + after_change "$1" "$3" +} + # ======================== Props files functions ======================== # Reset prop files reset_prop_files() { @@ -678,7 +904,7 @@ reset_prop_files() { # Changes files for PROPTYPE in $PROPSLIST; do - log_handler "Disabling prop file editing for '$PROPTYPTE'." + log_handler "Disabling prop file editing for '$PROPTYPE'." PROP=$(get_prop_type $PROPTYPE) SETPROP=$(echo "SET$PROP" | tr '[:lower:]' '[:upper:]') replace_fn $SETPROP "true" "false" $LATEFILE @@ -699,7 +925,7 @@ edit_prop_files() { log_handler "Modifying prop files$3." # Checks if editing prop files is enabled - if [ "$(get_file_value $LATEFILE "BUILDPROPENB=")" == 0 ]; then + if [ "$BUILDPROPENB" == 0 ]; then log_handler "Editing build.prop is disabled. Only editing default.prop." PROPSLIST=" ro.debuggable @@ -707,8 +933,8 @@ edit_prop_files() { " else # Checking if the device fingerprint is set by the module - if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ] && [ "$(get_file_value $LATEFILE "PRINTEDIT=")" == 1 ]; then - if [ "$(cat $SYSTEMLOC/build.prop | grep "$ORIGFINGERPRINT")" ]; then + if [ "$FINGERPRINTENB" == 1 ] && [ "$PRINTEDIT" == 1 ]; then + if [ "$(grep "$ORIGFINGERPRINT" $MIRRORLOC/build.prop)" ]; then log_handler "Enabling prop file editing for device fingerprint." replace_fn SETFINGERPRINT "false" "true" $LATEFILE fi @@ -727,7 +953,7 @@ edit_prop_files() { if [ "$PROPTYPE" == "ro.debuggable" ] || [ "$PROPTYPE" == "ro.secure" ]; then PROPVALUE=$(get_file_value /default.prop "${PROPTYPE}=") else - PROPVALUE=$(get_file_value $SYSTEMLOC/build.prop "${PROPTYPE}=") + PROPVALUE=$(get_file_value $MIRRORLOC/build.prop "${PROPTYPE}=") fi fi @@ -843,20 +1069,17 @@ reset_prop() { replace_fn $REPROP "true" "false" $LATEFILE # Updates prop change variable in propsconf_late - PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") if [ "$SUBA" ]; then if [ "$PROPCOUNT" -gt 0 ]; then PROPCOUNTP=$(($PROPCOUNT-1)) replace_fn PROPCOUNT $PROPCOUNT $PROPCOUNTP $LATEFILE fi fi - if [ "$(get_file_value $LATEFILE "PROPCOUNT=")" == 0 ]; then + if [ "$PROPCOUNT" == 0 ]; then replace_fn PROPEDIT 1 0 $LATEFILE fi - if [ "$2" != "file" ]; then - after_change "$1" - fi + after_change "$1" "$2" } # Use prop value @@ -876,15 +1099,12 @@ change_prop() { # Updates prop change variables in propsconf_late if [ -z "$SUBA" ]; then - PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") PROPCOUNTP=$(($PROPCOUNT+1)) replace_fn PROPCOUNT $PROPCOUNT $PROPCOUNTP $LATEFILE fi replace_fn PROPEDIT 0 1 $LATEFILE - if [ "$3" != "file" ]; then - after_change "$1" - fi + after_change "$1" "$3" } # Reset all module prop changes @@ -904,7 +1124,6 @@ reset_prop_all() { done # Updates prop change variables in propsconf_late - PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") replace_fn PROPCOUNT $PROPCOUNT 0 $LATEFILE replace_fn PROPEDIT 1 0 $LATEFILE @@ -914,7 +1133,7 @@ reset_prop_all() { # ======================== Custom Props functions ======================== # Set custom props custom_edit() { - if [ "$1" ] && [ "$(get_file_value $LATEFILE "CUSTOMEDIT=")" == 1 ]; then + if [ "$1" ] && [ "$CUSTOMEDIT" == 1 ]; then TMPLST="$(get_file_value $LATEFILE "${1}=")" if [ "$TMPLST" ]; then log_handler "Writing custom props." @@ -931,71 +1150,72 @@ custom_edit() { # Set custom prop value set_custprop() { if [ "$2" ]; then + # Reset the prop + reset_custprop "$1" "$(resetprop $1)" "bootstage" + # Set the prop PROPSBOOTSTAGE="CUSTOMPROPS" + PROPSTXT="default" if [ "$3" == "post" ]; then PROPSBOOTSTAGE="CUSTOMPROPSPOST" + PROPSTXT="post-fs-data" elif [ "$3" == "late" ]; then PROPSBOOTSTAGE="CUSTOMPROPSLATE" + PROPSTXT="late_start service" + elif [ "$3" == "both" ]; then + PROPSBOOTSTAGE="CUSTOMPROPSPOST CUSTOMPROPSLATE" + PROPSTXT="post-fs-data/late_start service" fi TMPVALUE=$(echo "$2" | sed 's| |_sp_|g') - CURRCUSTPROPS=$(get_file_value $LATEFILE "${PROPSBOOTSTAGE}=") - case "$CURRCUSTPROPS" in - *$1*) - TMPORIG=$(echo "$4" | sed 's| |_sp_|g') - TMPCUSTPROPS=$(echo "$CURRCUSTPROPS" | sed "s|${1}=${TMPORIG}|${1}=${TMPVALUE}|") - ;; - *) - TMPCUSTPROPS=$(echo "$CURRCUSTPROPS ${1}=${TMPVALUE}" | sed 's|^[ \t]*||') - ;; - esac - SORTCUSTPROPS=$(echo $(printf '%s\n' $TMPCUSTPROPS | sort -u)) + TMPORIG=$(echo "$4" | sed 's| |_sp_|g') + DLIMTMP=1 + for ITEM in $PROPSBOOTSTAGE; do + CURRCUSTPROPS=$(get_file_value $LATEFILE "${ITEM}=") + case "$CURRCUSTPROPS" in + *$1*) + TMPCUSTPROPS=$(echo "$CURRCUSTPROPS" | sed "s|${1}=${TMPORIG}|${1}=${TMPVALUE}|") + ;; + *) + TMPCUSTPROPS=$(echo "$CURRCUSTPROPS ${1}=${TMPVALUE}" | sed 's|^[ \t]*||') + ;; + esac + SORTCUSTPROPS=$(echo $(printf '%s\n' $TMPCUSTPROPS | sort -u)) - log_handler "Setting custom prop $1." - replace_fn $PROPSBOOTSTAGE "\"$CURRCUSTPROPS\"" "\"$SORTCUSTPROPS\"" $LATEFILE - replace_fn CUSTOMEDIT 0 1 $LATEFILE + log_handler "Setting custom prop $1 in $(echo $PROPSTXT | cut -f $DLIMTMP -d '/') stage." + replace_fn $ITEM "\"$CURRCUSTPROPS\"" "\"$SORTCUSTPROPS\"" $LATEFILE + replace_fn CUSTOMEDIT 0 1 $LATEFILE + DLIMTMP=$(($DLIMTMP + 1)) + done - if [ "$4" != "file" ]; then - after_change "$1" - fi + after_change "$1" "$4" fi } # Reset all custom prop values reset_all_custprop() { - CURRCUSTPROPS=$(get_file_value $LATEFILE "CUSTOMPROPS=") - CURRCUSTPROPSPOST=$(get_file_value $LATEFILE "CUSTOMPROPSPOST=") - CURRCUSTPROPSLATE=$(get_file_value $LATEFILE "CUSTOMPROPSLATE=") - log_handler "Resetting all custom props." # Removing all custom props - replace_fn CUSTOMPROPS "\"$CURRCUSTPROPS\"" "\"\"" $LATEFILE - replace_fn CUSTOMPROPSPOST "\"$CURRCUSTPROPSPOST\"" "\"\"" $LATEFILE - replace_fn CUSTOMPROPSLATE "\"$CURRCUSTPROPSLATE\"" "\"\"" $LATEFILE + replace_fn CUSTOMPROPS "\"$CUSTOMPROPS\"" "\"\"" $LATEFILE + replace_fn CUSTOMPROPSPOST "\"$CUSTOMPROPSPOST\"" "\"\"" $LATEFILE + replace_fn CUSTOMPROPSLATE "\"$CUSTOMPROPSLATE\"" "\"\"" $LATEFILE replace_fn CUSTOMEDIT 1 0 $LATEFILE - if [ "$1" != "file" ]; then - after_change "$1" - fi + after_change "Resetting all custom props" "$1" } # Reset custom prop value reset_custprop() { - if [ "$(echo $CUSTOMPROPS | grep $1)" ]; then - PROPSBOOTSTAGE="CUSTOMPROPS" - elif [ "$(echo $CUSTOMPROPSPOST | grep $1)" ]; then - PROPSBOOTSTAGE="CUSTOMPROPSPOST" - elif [ "$(echo $CUSTOMPROPSLATE | grep $1)" ]; then - PROPSBOOTSTAGE="CUSTOMPROPSLATE" - fi - TMPVALUE=$(echo "$2" | sed 's| |_sp_|g') - CURRCUSTPROPS=$(get_file_value $LATEFILE "${PROPSBOOTSTAGE}=") - log_handler "Resetting custom prop $1." - TMPCUSTPROPS=$(echo $CURRCUSTPROPS | sed "s|${1}=${TMPVALUE}||" | tr -s " " | sed 's|^[ \t]*||') + PROPSBOOTSTAGE="CUSTOMPROPS CUSTOMPROPSPOST CUSTOMPROPSLATE" + TMPVALUE=$(echo "$2" | sed 's| |_sp_|g') - # Updating custom props string - replace_fn $PROPSBOOTSTAGE "\"$CURRCUSTPROPS\"" "\"$TMPCUSTPROPS\"" $LATEFILE - if [ -z "$(get_file_value $LATEFILE "CUSTOMPROPS=")" ] && [ -z "$(get_file_value $LATEFILE "CUSTOMPROPSPOST=")" ] && [ -z "$(get_file_value $LATEFILE "CUSTOMPROPSLATE=")" ]; then + for ITEM in $PROPSBOOTSTAGE; do + CURRCUSTPROPS=$(get_file_value $LATEFILE "${ITEM}=") + TMPCUSTPROPS=$(echo $CURRCUSTPROPS | sed "s|${1}=${TMPVALUE}||" | tr -s " " | sed 's|^[ \t]*||') + # Updating custom props string + replace_fn $ITEM "\"$CURRCUSTPROPS\"" "\"$TMPCUSTPROPS\"" $LATEFILE + done + + if [ -z "$CUSTOMPROPS" ] && [ -z "$CUSTOMPROPSPOST" ] && [ -z "$CUSTOMPROPSLATE" ]; then replace_fn CUSTOMEDIT 1 0 $LATEFILE fi @@ -1004,19 +1224,12 @@ reset_custprop() { fi } -# Change what boot stage is used for custom prop -change_bootstage_custprop() { - reset_custprop "$1" "$(resetprop $1)" "bootstage" - set_custprop "$1" "$(resetprop $1)" "$2" -} - # ======================== Delete Props functions ======================== # Delete props prop_del() { - if [ "$(get_file_value $LATEFILE "DELEDIT=")" == 1 ]; then + if [ "$DELEDIT" == 1 ]; then log_handler "Deleting props." - TMPLST="$(get_file_value $LATEFILE "DELETEPROPS=")" - for ITEM in $TMPLST; do + for ITEM in $DELETEPROPS; do log_handler "Deleting $ITEM." TMPITEM=$( echo $(get_eq_right "$ITEM") | sed 's|_sp_| |g') resetprop -v $ITEM >> $LOGFILE 2>&1 @@ -1035,49 +1248,41 @@ prop_del() { # Set prop to delete set_delprop() { if [ "$1" ]; then - CURRDELPROPS=$(get_file_value $LATEFILE "DELETEPROPS=") - TMPDELPROPS=$(echo "$CURRDELPROPS ${1}" | sed 's|^[ \t]*||') + TMPDELPROPS=$(echo "$DELETEPROPS ${1}" | sed 's|^[ \t]*||') SORTDELPROPS=$(echo $(printf '%s\n' $TMPDELPROPS | sort -u)) log_handler "Setting prop to delete, $1." - replace_fn DELETEPROPS "\"$CURRDELPROPS\"" "\"$SORTDELPROPS\"" $LATEFILE + replace_fn DELETEPROPS "\"$DELETEPROPS\"" "\"$SORTDELPROPS\"" $LATEFILE replace_fn DELEDIT 0 1 $LATEFILE - if [ "$2" != "file" ]; then - after_change "Delete $1" - fi + after_change "Delete $1" "$2" fi } # Reset all props to delete reset_all_delprop() { - CURRDELPROPS=$(get_file_value $LATEFILE "DELETEPROPS=") - log_handler "Resetting list of props to delete." # Removing all props to delete - replace_fn DELETEPROPS "\"$CURRDELPROPS\"" "\"\"" $LATEFILE + replace_fn DELETEPROPS "\"$DELETEPROPS\"" "\"\"" $LATEFILE replace_fn DELEDIT 1 0 $LATEFILE - if [ "$1" != "file" ]; then - after_change "Delete $1" - fi + after_change "Delete $1" "$2" } # Reset prop to delete reset_delprop() { - CURRDELPROPS=$(get_file_value $LATEFILE "DELETEPROPS=") - log_handler "Resetting prop to delete, $1." - TMPDELPROPS=$(echo $CURRDELPROPS | sed "s|${1}||" | tr -s " " | sed 's|^[ \t]*||') + TMPDELPROPS=$(echo $DELETEPROPS | sed "s|${1}||" | tr -s " " | sed 's|^[ \t]*||') # Resetting prop to delete - replace_fn DELETEPROPS "\"$CURRDELPROPS\"" "\"$TMPDELPROPS\"" $LATEFILE - CURRDELPROPS=$(get_file_value $LATEFILE "DELETEPROPS=") - if [ -z "$CURRDELPROPS" ]; then + replace_fn DELETEPROPS "\"$DELETEPROPS\"" "\"$TMPDELPROPS\"" $LATEFILE + # Loading new value + . $LATEFILE + if [ -z "$DELETEPROPS" ]; then replace_fn DELEDIT 1 0 $LATEFILE fi - after_change "Delete $1" + after_change "Delete $1" "$2" } # ======================== Log collecting functions ======================== @@ -1091,9 +1296,9 @@ collect_logs() { for ITEM in $TMPLOGLIST; do if [ -f "$ITEM" ]; then case "$ITEM" in - *build.prop*) BPNAME="build_$(echo $ITEM | sed 's|\/build.prop||' | sed 's|.*\/||g').prop" + *build.prop*) BPNAME="build_$(echo $ITEM | sed 's|\/build.prop||' | sed 's|.*\/||g').prop" ;; - *) BPNAME="" + *) BPNAME="" ;; esac cp -af $ITEM ${TMPLOGLOC}/${BPNAME} >> $LOGFILE 2>&1 @@ -1112,7 +1317,7 @@ collect_logs() { log_handler "$ITEM not available." fi ;; - *) log_handler "$ITEM not available." + *) log_handler "$ITEM not available." ;; esac fi diff --git a/config.sh b/config.sh index 3562d04..4c95794 100644 --- a/config.sh +++ b/config.sh @@ -4,41 +4,19 @@ # by topjohnwu # ########################################################################################## -########################################################################################## -# -# Instructions: -# -# 1. Place your files into system folder (delete the placeholder file) -# 2. Fill in your module's info into module.prop -# 3. Configure the settings in this file (config.sh) -# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh -# 5. Add your additional or modified system properties into common/system.prop -# -########################################################################################## - ########################################################################################## # Configs ########################################################################################## -# Set to true if you need to enable Magic Mount -# Most mods would like it to be enabled AUTOMOUNT=true - -# Set to true if you need to load system.prop PROPFILE=false - -# Set to true if you need post-fs-data script POSTFSDATA=true - -# Set to true if you need late_start service script -LATESTARTSERVICE=false +LATESTARTSERVICE=true ########################################################################################## # Installation Message ########################################################################################## -# Set what you want to show when installing your mod - print_modname() { MODVERSION=$(echo $(get_file_value $INSTALLER/module.prop "version=") | sed 's|-.*||') ui_print "*******************************" @@ -51,19 +29,6 @@ print_modname() { # Replace list ########################################################################################## -# List all directories you want to directly replace in the system -# Check the documentations for more info about how Magic Mount works, and why you need this - -# This is an example -REPLACE=" -/system/app/Youtube -/system/priv-app/SystemUI -/system/priv-app/Settings -/system/framework -" - -# Construct your own list here, it will override the example above -# !DO NOT! remove this if you don't need to replace anything, leave it empty as it is now REPLACE=" " @@ -72,52 +37,24 @@ REPLACE=" ########################################################################################## set_permissions() { - # Only some special files require specific permissions - # The default permissions should be good enough for most cases - - # Here are some examples for the set_perm functions: - - # set_perm_recursive (default: u:object_r:system_file:s0) - # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644 - - # set_perm (default: u:object_r:system_file:s0) - # set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0 - # set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0 - # set_perm $MODPATH/system/lib/libart.so 0 0 0644 - - # The following is default permissions, DO NOT remove set_perm_recursive $MODPATH 0 0 0755 0644 - - # Permissions for the props file set_perm $MODPATH/system/$BIN/props 0 0 0777 - # Permissions for boot scripts set_perm $LATEFILE 0 0 0755 - set_perm $POSTFILE 0 0 0755 } -########################################################################################## -# Custom Functions -########################################################################################## - -# This file (config.sh) will be sourced by the main flash script after util_functions.sh -# If you need custom logic, please add them here as functions, and call these functions in -# update-binary. Refrain from adding code directly into update-binary, as it will make it -# difficult for you to migrate your modules to newer template versions. -# Make update-binary as clean as possible, try to only do function calls in it. - - ########################################################################################## # Installation variables and functions for the Magisk module "MagiskHide Props Config" -# by Didgeridoohan @ XDA Developers. +# Copyright (c) 2018-2019 Didgeridoohan @ XDA Developers. +# Licence: MIT ########################################################################################## # Finding file values get_file_value() { - cat $1 | grep $2 | sed "s|.*$2||" | sed 's|\"||g' + grep $2 $1 | sed "s|.*$2||" | sed 's|\"||g' } # Get left side of = get_eq_left() { - echo $1 | sed 's|=.*||' + echo $1 | cut -f 1 -d '=' } # Get first word in string get_first() { @@ -141,33 +78,37 @@ $BOOTMODE && IMGPATH=$BIMGPATH || IMGPATH=$MOUNTPATH if [ "$MAGISK_VER_CODE" -ge 17316 ]; then POSTPATH=$ADBPATH/post-fs-data.d SERVICEPATH=$ADBPATH/service.d - POSTHOLDER=$ADBPATH/post-fs-data.d/propsconf_post LATEHOLDER=$ADBPATH/service.d/propsconf_late else POSTPATH=$IMGPATH/.core/post-fs-data.d SERVICEPATH=$IMGPATH/.core/service.d - POSTHOLDER=$BIMGPATH/.core/post-fs-data.d/propsconf_post LATEHOLDER=$BIMGPATH/.core/service.d/propsconf_late fi POSTFILE=$POSTPATH/propsconf_post -UPDATEPOSTFILE=$INSTALLER/common/propsconf_post LATEFILE=$SERVICEPATH/propsconf_late POSTLATEFILE=$POSTPATH/propsconf_late UPDATELATEFILE=$INSTALLER/common/propsconf_late +MIRRORLOC=/sbin/.magisk/mirror/system if [ -z $SLOT ]; then - SYSTEMLOC=/system CACHELOC=/cache else - SYSTEMLOC=/system_root/system CACHELOC=/data/cache fi +CONFFILELST=" +$CACHELOC/propsconf_conf +/data/propsconf_conf +/sdcard/propsconf_conf +" INSTLOG=$CACHELOC/propsconf_install.log UPDATEV=$(get_file_value $UPDATELATEFILE "SCRIPTV=") UPDATETRANSF=$(get_file_value $UPDATELATEFILE "SETTRANSF=") NOTTRANSF=$(get_file_value $UPDATELATEFILE "NOTTRANSF=") SETTINGSLIST=" FINGERPRINTENB +PRINTMODULE PRINTEDIT +PRINTVEND +DEVSIM BUILDPROPENB FILESAFE BUILDEDIT @@ -177,9 +118,18 @@ PROPEDIT CUSTOMEDIT DELEDIT REBOOTCHK +PRINTCHK OPTIONLATE OPTIONCOLOUR OPTIONWEB +OPTIONUPDATE +BRANDSET +NAMESET +DEVICESET +RELEASESET +IDSET +INCREMENTALSET +DESCRIPTIONSET " PROPSETTINGSLIST=" MODULEDEBUGGABLE @@ -188,6 +138,13 @@ MODULETYPE MODULETAGS MODULESELINUX MODULEFINGERPRINT +SIMBRAND +SIMNAME +SIMDEVICE +SIMRELEASE +SIMID +SIMINCREMENTAL +SIMDESCRIPTION CUSTOMPROPS CUSTOMPROPSPOST CUSTOMPROPSLATE @@ -206,7 +163,7 @@ USNFLIST="xiaomi-safetynet-fix safetynet-fingerprint-fix VendingVisa DeviceSpoof # Log functions log_handler() { echo "" >> $INSTLOG - echo -e "$(date +"%m-%d-%Y %H:%M:%S") - $1" >> $INSTLOG 2>&1 + echo -e "$(date +"%Y-%m-%d %H:%M:%S:%N") - $1" >> $INSTLOG 2>&1 } log_start() { if [ -f "$INSTLOG" ]; then @@ -227,8 +184,10 @@ log_print() { # Places various module scripts in their proper places script_placement() { if [ -f "$LATEFILE" ]; then - FILEV=$(get_file_value $LATEFILE "SCRIPTV=") - FILETRANSF=$(get_file_value $LATEFILE "SETTRANSF=") + # Load module settings + load_settings + FILEV=$SCRIPTV + FILETRANSF=$SETTRANSF else FILEV=0 FILETRANSF=$UPDATETRANSF @@ -236,8 +195,6 @@ script_placement() { log_print "- Installing scripts" cp -af $INSTALLER/common/util_functions.sh $MODPATH/util_functions.sh >> $INSTLOG 2>&1 cp -af $INSTALLER/common/prints.sh $MODPATH/prints.sh >> $INSTLOG 2>&1 - cp -af $UPDATEPOSTFILE $MODPATH/propsconf_post >> $INSTLOG 2>&1 - cp -af $UPDATEPOSTFILE $POSTFILE >> $INSTLOG 2>&1 cp -af $UPDATELATEFILE $MODPATH/propsconf_late >> $INSTLOG 2>&1 if [ "$FILEV" ]; then # New script @@ -340,9 +297,29 @@ print_files() { log_handler "Creating files" for OEM in $OEMLIST; do echo -e "PRINTSLIST=\"" >> $MODPATH/printfiles/${OEM}\.sh - cat $MODPATH/prints.sh | grep $OEM >> $MODPATH/printfiles/${OEM}\.sh + grep $OEM >> $MODPATH/printfiles/${OEM}\.sh $MODPATH/prints.sh echo -e "\"" >> $MODPATH/printfiles/${OEM}\.sh done + # Check for updated fingerprint + device_print_update +} + +device_print_update() { + if [ "$OPTIONUPDATE" == 1 ]; then + if [ "$FINGERPRINTENB" == 1 -o "$PRINTMODULE" == 0 ] && [ "$PRINTEDIT" == 1 ] && [ "$MODULEFINGERPRINT" ]; then + TMPDEV="${VARBRAND}\.${VARNAME}\.${VARDEVICE}" + TMPPRINT=$(echo $PRINTSLIST | grep $TMPDEV ) + if [ "$TMPDEV" ] && [ "$TMPPRINT" ]; then + if [ "$(echo $MODULEFINGERPRINT | sed 's|\_\_.*||')" != "$(echo $TMPPRINT | cut -f 2 -d '=' | sed 's|\_\_.*||')" ]; then + log_handler "Updating module fingerprint." + sed -i "s|MODULEFINGERPRINT=$MODULEFINGERPRINT|MODULEFINGERPRINT=$(echo $TMPPRINT | cut -f 2 -d '=')|" $LATEFILE + log_handler "Changing device fingerprint to $(echo $TMPPRINT | cut -f 2 -d '=' | sed 's|\_\_.*||')." + # Reloading module settings + load_settings + fi + fi + fi + fi } # Updates placeholders @@ -361,7 +338,7 @@ build_prop_check() { log_print "- Checking for build.prop conflicts" for D in $(ls $IMGPATH); do if [ "$D" != "$MODID" ]; then - if [ -f "$IMGPATH/$D/system/build.prop" ]; then + if [ -f "$IMGPATH/$D/system/build.prop" ] || [ "$D" == "safetypatcher" ]; then NAME=$(get_file_value $IMGPATH/$D/module.prop "name=") ui_print "!" log_print "! Another module editing build.prop detected!" @@ -412,12 +389,69 @@ install_check() { fi } -# Check for late_start service boot script in post-fs-data.d, in case someone's moved it +# Check for late_start service boot script in post-fs-data.d, in case someone's moved it and also delete the old propsconf_post boot script if present post_check() { if [ -f "$POSTLATEFILE" ]; then log_handler "Removing late_start service boot script from post-fs-data.d." rm -f $POSTLATEFILE fi + if [ -f "$POSTFILE" ]; then + log_handler "Removing old post-fs-data boot script from post-fs-data.d" + rm -f $POSTFILE + fi + if [ -f "$CACHELOC/propsconf_postfile.log" ]; then + log_handler "Removing old post-fs-data log from /cache." + rm -f $CACHELOC/propsconf_postfile.log + fi +} + +# Save props values from fingerprint parts +print_parts() { + DLIM1=1 + DLIM2=1 + for ITEM in $PROPSETTINGSLIST; do + case $ITEM in + SIMDESCRIPTION) # Do nothing with the description variable + ;; + SIM*) + TMPVAR="$(echo $ITEM | sed 's|SIM||')" + TMPVALUE=$(echo $1 | sed 's|\:user/release-keys.*||' | cut -f $DLIM1 -d ':' | cut -f $DLIM2 -d '/') + eval "VAR${TMPVAR}='$TMPVALUE'" + DLIM2=$(($DLIM2 + 1)) + if [ "$DLIM2" == 4 ]; then + DLIM1=2 + DLIM2=1 + fi + ;; + esac + done + VARDESCRIPTION="${VARNAME}-user $VARRELEASE $VARID $VARINCREMENTAL release-keys" +} + +# Update the device simulation variables if a fingerprint is set +devsim_update() { + if [ "$MODULEFINGERPRINT" ]; then + log_handler "Updating device simulation variables." + print_parts $MODULEFINGERPRINT + for ITEM in $PROPSETTINGSLIST; do + case $ITEM in + SIM*) + SUBA="$(get_file_value $LATEFILE "${ITEM}=")" + TMPVAR="$(echo $ITEM | sed 's|SIM|VAR|')" + TMPPROP="$(eval "echo \$$TMPVAR")" + sed -i "s|${ITEM}=\"${SUBA}\"|${ITEM}=\"${TMPPROP}\"|" $LATEFILE + ;; + esac + done + # Reload module settings + load_settings + fi +} + +# Load module settings and reapply the MODPATH variable +load_settings() { + . $LATEFILE + MODPATH=$MOUNTPATH/$MODID } # Installs everything @@ -429,23 +463,38 @@ script_install() { script_placement log_print "- Updating placeholders" placeholder_update $LATEFILE CACHELOC CACHE_PLACEHOLDER "$CACHELOC" + placeholder_update $LATEFILE COREPATH CORE_PLACEHOLDER "$COREPATH" placeholder_update $MODPATH/util_functions.sh BIN BIN_PLACEHOLDER "$BIN" placeholder_update $MODPATH/util_functions.sh USNFLIST USNF_PLACEHOLDER "$USNFLIST" - placeholder_update $MODPATH/util_functions.sh SYSTEMLOC SYSTEM_PLACEHOLDER "$SYSTEMLOC" + placeholder_update $MODPATH/util_functions.sh MIRRORLOC MIRROR_PLACEHOLDER "$MIRRORLOC" placeholder_update $MODPATH/util_functions.sh CACHELOC CACHE_PLACEHOLDER "$CACHELOC" placeholder_update $MODPATH/util_functions.sh LATEFILE LATE_PLACEHOLDER "$LATEHOLDER" - placeholder_update $MODPATH/util_functions.sh POSTFILE POST_PLACEHOLDER "$POSTHOLDER" placeholder_update $MODPATH/util_functions.sh MODVERSION VER_PLACEHOLDER "$MODVERSION" - placeholder_update $MODPATH/util_functions.sh BBWWWPATH BB_PLACEHOLDER "$BBWWWPATH" - placeholder_update $POSTFILE COREPATH CORE_PLACEHOLDER "$COREPATH" - placeholder_update $POSTFILE CACHELOC CACHE_PLACEHOLDER "$CACHELOC" - placeholder_update $LATEFILE POSTFILE POST_PLACEHOLDER "$POSTHOLDER" - placeholder_update $LATEFILE COREPATH CORE_PLACEHOLDER "$COREPATH" placeholder_update $MODPATH/system/$BIN/props LATEFILE LATE_PLACEHOLDER "$LATEHOLDER" placeholder_update $MODPATH/system/$BIN/props COREPATH CORE_PLACEHOLDER "$COREPATH" + load_settings + devsim_update print_files ui_print "" ui_print "- Make sure to have Busybox installed." ui_print "- osm0sis' Busybox is recommended." ui_print "" + log_handler "Installation complete." + # Checks for configuration file + CONFFILE="" + for ITEM in $CONFFILELST; do + if [ -s "$ITEM" ]; then + CONFFILE="$ITEM" + break + fi + done + if [ "$CONFFILE" ]; then + . $MODPATH/util_functions.sh + LOGFILE=$INSTLOG + MODPATH=$MOUNTPATH/$MODID + ui_print "- Configuration file found." + ui_print "- Installing..." + ui_print "" + config_file + fi } diff --git a/module.prop b/module.prop index 877e651..da13d97 100644 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=MagiskHidePropsConf name=MagiskHide Props Config -version=v2.7.2-v42 -versionCode=36 +version=v3.0.0-v42 +versionCode=37 author=Didgeridoohan description=Change your device's fingerprint, to pass SafetyNet's CTS Profile check. Edit prop files for better root hiding. Set/reset prop values set by MagiskHide. Change any prop values easily, and set your own custom props. minMagisk=17000 diff --git a/system/binpath/props b/system/binpath/props index 98516b59204704683601c8ed997045fbfcf31339..105dd22442b8df14c5c909fe3348a303cdcd67ee 100644 GIT binary patch delta 7768 zcmcgxeQ;CPm7j-=ZOO*iwfqTot{;kR0T#9~{(#6vwuGa`A3~B1gaji?&sd3&jPz{d zSjMosnb~fJ#`v@iX<8_3+YGalbUd#K>6WIjo$yUQx_@-0-4vMFZvV(kLp!tk$4Vbv<*eVW zHX7P22G^i_*w>~UG-L?^fuM0Ge%>|Kz%PvJ*tcEma}(^&Z@_OaU+W(XDhpp+yMWIqwjEh4emh&VMF z^ve?DuXzs!59Go?Yi=$d5@E5^RPURRNKl$at&(w6j})7Xg(5PU@W;uRBt;0P4Z^>6 z)WVH5^>FoOh4SY$l3+5=_0D^wv1nB0S~brN&MSx4It2K6QF{*86coQwvQ&IjXoE;s z7k(~xl`9_=CxpUXuE9R1$L(3&@6duWe#ggCT@j-_R&OKKOzcLlUyQZtz z^fbz`(*G0+hdi#n5$B+Tk%_Rpt<=E2(lHSBoAM0wn{TfVj&zro8w>_19G6h<^iQ3! ziST)Q>8N?GZ+@CeO&ZBCn!~gd2}WaST4)%@0bfiS3rnQW>mr_^fw;vyr}CMnmufJK zhuFW+IMe!&+vge@+~eej8rYW)KP&$m=<3Mj2kU+M87d_V?#pZT%s-~`tyD_f48C@A z{Tew+{F9U6SvCm2>mcyL_Wkhj+STxvuNt9frV9S$iNd9~vfQR2{qPZECchv~n;JcL@4CzPtgP5~a^{POW#j0yXxq)b8JQO>ujBF|p`0WHY zX9;UmB{-ZTUe^G-R$R6Y?JFKSJn9d~p=q>5w9RHsbx=E33vV=5136I$4}M^PlZ{)@ zb*`K@!~BV=L2u}&Jb?}!nId6nS_tEWrD#Xj`r>+5ou-xkHA2Icg;h}p6FCKNM><)IP{`K z=#6Mc%Mc1qyyV9{k8Cj&w234Xp$V-HR=-uRLFQ!uoXqzWvQYC~E0sle=q1GHjbG zi{Cyx*VMQmnv;IS0!I^heg}~!Bqp)fhp`Zy$|h2;ks^Nd2-PSJhTdV1N1gM`2Saf> z8BEUl2HYd|ep@phTysS|H*H1hiu|;_GT1dCyYUbRFYa-eHFjhwj-iOktopL<%Ji{q z1*eAl)^b9tiG<=LFcphQ5ji|d%<2J=$N>*}C*Ytv09(SVp}(=9Yg7#z)TYs} z`DwXzr#XYBQ&LyQ;shsTvEXxY^&?&6k0<;2H7XrV#jDuYF1UB0vN+RDmRp)?GDeer zL9Gk!zb!5}2kkxmPJWrBfnR430~?Dn28YY5O?&1^gLb2-dFI{h#_2)1v-k3x zJuVglbp**VPPJgjR86zq+&D|hz|2L}8INvG6_l9*{lH-D@;L|4%Lq4Sx839O?jXS^ z&KgkTZqJb0W^O1sB*_@@qLZWY?4(4@bP@b}pIE~##e)>w&&_k{nt2pOv_P@Ft{^q$ zb;2L7mYbz%e;6-bPim`I#jfWT7=|O|;+hnR*Xe_|KPU^Vyi`4vwpPtvE73CUEd2zd z5t`(ZYE3E}&OTRad+1VD(rI!5Q@UQU@JTlT@}qhvx~b+cCno3OKo$JH)6}lo4#Az# z?_v_Se6BupB7a&sjY~2ao27(sw`3AN`bNQmZvv@soPr246AFj%vdEY}9tx;2m}`(B zxl}x)T(m_2DJJ{z#_4^=b=1g23KH~X8V^#=Ol1hN_)2NvAFW@Zz7L-#OfYnPU3;85 z0cM#DCo<0^4Ugyjq^?=26ZSI%v!8~?W|c=QYDJ-fQvumJ7V}3ihV^*t44bIPL9?>H z`IgKj5&vNt672&t?y~HEZo2e&9Z!A=CYP&MBTD8dDoAUJ>)2E%9JEeLu{ee|YfNGY z*gWTP_B-upj_M9Yy){E2l+#54RECgkU&JmH3B)8!zOp}zYX^Hh&H?A3&)!d&z$a3v zg@td_DoW1<2};KOMV{?t&4VfL+|c*1L8xnIkSqukn(_<;dxLvx}f zu{F_}*p_HZ1QU)lyu$YMv@olR3Qg8}%&a;w{*Th?qf+TZnY1!JZ6{MHOP>R<^W@r1 zsT9gwPv=G4$Vlpxh-b={&gA8%<;BU09DYO%$uBS^@obC^u4Yx{-{^phzlx>O+?RTO z(rMGElF2ybzxvR^(V5B;7sAIk*TAngKLhv9)fcA2D_HzyMG6^NyvcZ=J0uS#=@$z2 ziMoXVts7Zs#gSaIg^kdnR#s8a2(II${(v z4bQH|%z_a^!=em;!nu||<#aCuu!0i&hor|kk-Ku1P$A-~P| z4CXMc=3wbbQ$C`yDJhOnkRMqq-FW(8XT^++L44dl6_#n9p0vWN?PB>C@PpHB=2a;B zmc8XAYUckUkvh{$B=YzY!Hey?%2r;D`!~Sd_VIK@(7wrcJ9FV{9b1cag7b6>*GlT( zvySe^(la(&lrx>7RgX&yb5D&y&s$r;*;NFmm$$=!t>|&rDxcWuR~2}i4rkABUmqCZ~|ubnmYr@haMKRXPRwBI#2yq7LkF4|uc zil}|`4h;{YK{XzdNizsXN|aZ7|7lg`%zd#0j{jW_oZcn#)UIsldwwlP~0L5pA{4Oq<3X^V1Jx=6c?SI(Eft*QceeSCxR`k}jY zXtBzwyczmTD+%+>COFWSuRI8UgAa+&v?&J;%x+YE6|O$|s5$;XZ<(t`#Skg;D2GF0Jz67856Ga3HqXBH}=;K;LOu}I{Vs5s;J2TJz&lf#?bWi#s z%a`wjkrZ2068wB-b7N~7K&8U7P^)XU82&f>=|#caqa(~x*u^UcW~;d!nBjYK=dS1ZYtqs<}pBK!@ ziN52hiJC{B748?6BKLac25|pa2^=_1^3{0FZnY>;1#tWrw!UbCu!Eh=tjwRN6LK9` zxlo_F{#R4^Y<#!!>eu&aUQxa{r1J{pCrfQvd@*XGiuO+6XFsim#jjMs*G(>S?tYSU;3w@AxQh!e7{`C!h=B5*$t1g#k0zxA6^om=4@3iHt<;pueuxWcIW;*zrQC$|Jx_{BQq(og$VDcj!vr2y{B-5|PnS6RG4wx9*xvN!LVJloO6-Jiq>(lY> z%+;F5L_H?RyGC*uf@N=8Ch%V)*g99i0ls#b;LTp-v UogMf&d#8zotrGlv|4zey15?(p4*&oF delta 2948 zcmbVOdr*|u6`zmg_3bW;u)JaQx~vF9Hy|n_2+Cu@Et}nSA1nbWEby_cuFIBPG$kf# z+UeA4!sBR3G)5<}PL0VZxoFa6h>}UBZAc}yYC@s`lkq_+IPG87cBZ}eev1T&(uNnv5mvM0R>%88Hc! z$KcuE%u2qeWu35@ZzLAy;6#iJei!vRC6UX>bC zp*L3QEM|+|Xww->i_}?Aa$Lza>x=sW3Yt>oqO4qRqr$}-YC79J=P-ovn#(bE#5DKS{g~Mod3g}WXY)M-{_n&WkbaxmWPV44) zyj=B%1@MtF2BNh0>4vh$B^=x;%z$@Sq`~LrIsdUX~W@5IO%rmEGSyJ60Y!f;HD9|RLZB9?8;74vRYU*@* zTC~27cAr|xv!Br1){fLpZwqP>TAiJq0F$CXJGFFop!N>8%k6b~f{Vc08`Gt;OT*tc zYLbJ>536d`aPcRJptVFi%EzqcHmBG1|M&+-EEVCRHr)~ySvP<8qQ}JqIAzV_TikwU zlSgPl@Ta&8NVct`7T@o5<8Y779r6S0AlK0ZXE!9lJC3#=V2*2Qma=W5ExK}DslBqY zq}0GN=3;FUyjGh**OXawR$ZCh62uEA##?l@C(R6rsmq73sx*p}R9b1a#ndH(t8Nk1 zlT%xR-e|9(f{V2&_(a_SmVQc_Mr9_ukupw=mb(Hd7q|f>jO$pTTMs@&3dWT*cke9h0K=A3)U7Cy&9tCVzi2T?^1R9H)CO|DguA}v%iRBEr!uOaq#++GW_pf>?aWJ-E)yjh%)Zo7tg`q^M!!BQX%n$ zSmH$-NV^xnHP9qy4YqXI?zP z!Bj;Ge6rFFA3wej?j2kTVJ|NQ`yngrdpQM+pdsJe$-J22eTU8P&LIN7(ntztH0^?L&^GF8EJ88MjFmt>1qn$D)W_K=XCTbB6v0q&TIw89u(C~%vIlb2L&3~wI38%s4Qbs6B(aA0P`U$*ev}T^&dVj@ z{ILjTL>PZzNHxcI2Ob+~iy+-iiJgC)CcXa3LU3JP&c@$fF2?+oKXaipso?6T#o`2g zc0CL+$nbd)Y#5UVzkWP+jhR_LU(H5gY%gB+#RvyImz1%n!cAHcCBRJA0_PSbtPfuy zmr9);PlMRY@bJ|aLo_~~*KZ{Z*haM5+%4oSf-;2`cK|U~w7NZlKMPllPjDr^>@1Xy zbaQ3optcI$&IW4IKusE$2~t0#M_A#5^y{n+Z59t(d~dMsoP+8MDVM!co}gtLs*2R! z?P{su@e8wvCRZ(ObxWI_eu1!6)Kim&EakJk+nI0W?a136Xd^L5`NBeiXTkVHe5l}e zHbeGT>o^~7{mLbQu^ZJiNgwfYGT&ST?-kE`HIWp)xtN;GdwiU{#Y4lbcxv?hI-?R! z-a>3i_Uw4@KvTj^5s#Wvuo=P9Z!?Q;F`dEnxBFqqWG1L4Bf&nYh4D?1u$PQc^^q_< zna!<+JCjSee2D#KC*!9@S86iZ*g=cLrH@nm&2G5xx3>rdci&kE$M4jT*{Z1mNnREY z9aC#1E6F%8wNkQ*jJK!qLRM!%&-F#Hc3LXQCy;(RgBbXx3(5Z*(>dgSxKRV#-K75l DrXlvs