- Backing up /system/build.prop through a script in /system/addon.d
- Flashing my own file using a zip after every update
- Restoring previous build.prop using a Editor app and reboot
- Manually change or add every desired entry and reboot
So this flashable zip which works as follows:
- Somewhere on the device is a simple text file in which all those entries are that shall be changed or added to /system/build.prop (In my case it's /sdcard/tweak.prop)
- After mounting /system and /data (not if they are already) and setting write permissions to /system/build.prop the zip
extracts a shell script to /tmp/tweakprop.sh This scriptscans the text file (aborts if not found) and looks for changed or new entries in /system/build.prop in order to apply them. Changed entries will be overridden, new ones will be added, entries existing in /system/build.prop but not in your personal file will be ignored- When tweaking is done, it just
removes /tmp/tweakprop.sh andunmounts /system and /data (only if they weren't mounted before) and reverts /system/build.prop's permissions to rw-r--r--
update-binary
PHP Code:
#!/sbin/sh
## /META-INF/com/google/android/update-binary version 0.5 | tweakprop http://forum.xda-developers.com/showthread.php?t=2664332
## credits for ui_print() go to chainfire
OUTFD=$2
ui_print() {
echo -n -e "ui_print $1\n" > /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" > /proc/self/fd/$OUTFD}
ui_print ""ui_print "###############################"ui_print "# tweakprop 0.5 #"ui_print "# --by klenamenis-- #"ui_print "###############################"ui_print ""
build=/system/build.prop## personal file's name located anywhere on your internal storagename=tweak.prop
ui_print "Mount system partition.."mount /system
mount -o rw,remount /system
mount -o rw,remount /system /system
ui_print "Set write permissions for $build.."chmod 0666 $build
ui_print "Mount data partition.."mount /data
mount -o rw,remount /data
mount -o rw,remount /data /data
## search for files called $name and use first occurrenceui_print "searching personal file..."tweak=$(find /sdc* /sto* /ext* -name $name -type f -follow 2>/dev/null | sed 1q)
## abort execution if file is not found or emptytest -s $tweak && ui_print "..$tweak found and not empty" || (ui_print "ERROR: Personal file $name not found or empty, script aborted!s"; exit 0)
## loop trough $tweakui_print ""ui_print "scanning $tweak..."
## read only lines not beginning with #, not being empty, and
## matching any valid entry pattern (someVAR=someVAL), e.g.
## net.bt.name=Android, omni.device=n7100, url.legal=http://www ...
##
## add blank line at end of file to not ignore last linesed -r '/(#.*|^ *$)/d;/.*=.*/!d;$a' $tweak | while read linedo
## get entry from $tweak
entry=$(echo $line | sed "s/=.*//")
## if variable already present in $build
if cat $build | grep -q $entry
then
## override value in $build if different
if ! cat $build | grep -q $(cat $tweak | grep $entry)
then
ui_print "..value of $entry overridden"
sed -i "s/^${entry}=.*$/${line}/g" $build
fi
## I could simply override every existing line in much less code, but this way
## your recovery log won't be spamed with non-necessary " value of $entry overridden"
else
## append entry to $build
ui_print "..entry $entry added"
echo $line >> $build
fi
done
ui_print "..Tweaks successfully applied!"
ui_print "Restoring original permissions for $build.."chmod 0644 $build
ui_print "Unmounting system and data partitions.."umount /system
umount /data
ui_print "..Script finished!"exit 0
example.txt
Code:
# ====================================== # | Dynamic automated build.prop editing | # | by klenamenis | # ====================================== # # personal file located at /sdcard/0/tweak.prop # # # for help, please visit official XDA-Thread: # http://forum.xda-developers.com/showthread.php?p=50683717 # # # lines beginning with # will be ignored # already existing entries will be overridden, new one's added # # for valid/working build.prop configurations, ask google # # # simply add your entries below ro.sf.lcd_density=240
The zip flashes well on TWRP, CWM and Devil's recovery.
DISCLAIMER: I am not responsible for any damage you cause using my zip!
Changelog
- initial release
version 0.2:
- ignore lines in personal file not matching a valid entry pattern (someVAR=someVAL) to not mess up /system/build.prop and support personal structuring inside the file like "# media tweaks #", "# dalvik section #", etc.
- code cleaned up
version 0.2.1:
- typo fixed in line 24 of tweakprop.sh so the if-statement asks for the correct file (thanks to the_pirate_predator)
version 0.3:
- changed the while-loop to get it's input directly from sed, which makes a second buffer file obsolete
version 0.3.5:
- example.txt provided as tweak.prop template
- ignore lines beginning with # or being empty
version 0.4:
- instead of a fixed path, the personal file gets searched on internal storage (file name can be set in the script) so you can put your file anywhere - no more problems with /sdcard/ or /sdcard/0/ on different devices
- personal file must not be empty, otherwise script aborts#
- only override really different entry values in order to prevent "... value of someVAR overridden" spam in recovery log
version 0.4.5:
- fixed last line of personal file being ignored due to deleting all empty lines before
- speed up search for personal file, now looking on internal storage and even on external SD card if nothing was found before (ext. SD neither gets checked if present, nor mounted or unmounted, just trying to search on it silently)
version 0.4.5a:
- same as 0.4.5a, but personal file is inside the zip and gets extracted to /tmp/tweak.prop, no need to have one on the internal storage
version 0.4.6(a):
- output not shown in TWRP fixed, now works as it should
version 0.5:
- code cleanup: everything's now in the update-binary, resulting in much less code and faster execution time
- output to recovery should now work on all device-recovery combinations
No comments:
Post a Comment