[ZIP] Dynamic automated build.prop editing

What about an app? See post #90 for more infos, let me know what you think!


  • Total voters
    146
Search This thread

Lownita

Senior Member
Jun 14, 2011
2,274
378
Germany
I want to achieve the following two tasks by flashing a .zip file in recovery:

1. Open the following file:
Code:
/system/etc/permissions/handheld_core_hardware.xml​
Add in the following lines right before the </permissions> closing tag at the end:
Code:
<feature name="android.software.vr.mode" />
<feature name="android.hardware.vr.high_performance" />

2. Open
Code:
/system/build.prop
Add this line:
Code:
ro.product.device=sailfish

So how can I do it? :)
 

KrisM22

Senior Member
Sep 12, 2010
3,961
1,318
many ways to guide, many ways to heal
Before doing this, backup your ROM in TWRP, since if anything goes wrong you won't be able to boot your ROM, and you'll have to boot to TWRP and restore that nandroid.

LineageOS ROM 5-18-2017, opengapps nano 5-18. Magisk(hide)

This is the result of many tests:
Huge thanks for this.
I made a tweak.prop and put copies on both internal storage and SDcard.

I flashed 5._MOD_build_prop.zip which was in a separate folder with nothing else, in internal storage.

I had to put a carriage return(enter) after BACKUP=n as well as the extra one at the end.

It puts the mod at the end of /system/build.prop

This is my tweak.prop
Code:
BACKUP=n

ro.build.fingerprint=motorola/osprey_retus_2gb/osprey_u2:6.0/MPI24.65-25/28:user/release-keys
remember to put an EXTRA line feed/carriage return after BACKUP=n, and at the end.

WORKED!

THANKS!
 

Attachments

  • Screenshot_2017-05-18-21-30-34.png
    Screenshot_2017-05-18-21-30-34.png
    172 KB · Views: 646
  • tweak.txt
    105 bytes · Views: 215
Last edited:

jerethi

Senior Member
So... I know this is totally exactly what I have been looking for, as I have been flashing nightly builds of AICP for my 5X. However, I have absolutely no idea how to get this up and running. I understand this is a total noob question, but can someone take me through step by step how I would set this up?
 

HTalaia

New member
Mar 3, 2012
4
1
Help :)

Hi,

I was searching for a solution for a Vodafone Tablet that i have (known as Vodafone Tab Prime 7, or VDF 1400). I've been looking for a solution for a long time and i found that this one is very difficult to root or to change the recovery because it's very well locked by vodafone (and vodafone is no longer supporting this tablet).
This tablet is stuck on Android 6.0.1 (it's old, i know, but for the usage it is ok) and i would like to change the build.prop in order to change to userdebug to activate the multiwindow feature.
I have tried the zip file to change the build.prop but when i try to apply the zip on the recovery (stock) it returns the error "E: footer is wrong and E: signature verification failed".
Can anyone help me, please?

I am a noob in this subjects and i need help to solve this
 
Hi,

I was searching for a solution for a Vodafone Tablet that i have (known as Vodafone Tab Prime 7, or VDF 1400). I've been looking for a solution for a long time and i found that this one is very difficult to root or to change the recovery because it's very well locked by vodafone (and vodafone is no longer supporting this tablet).
This tablet is stuck on Android 6.0.1 (it's old, i know, but for the usage it is ok) and i would like to change the build.prop in order to change to userdebug to activate the multiwindow feature.
I have tried the zip file to change the build.prop but when i try to apply the zip on the recovery (stock) it returns the error "E: footer is wrong and E: signature verification failed".
Can anyone help me, please?

I am a noob in this subjects and i need help to solve this

Its not meant to be flashed using the stock recovery.

You need a custom recovery to use this script, like TWRP.

Judging by your story, you wont be able to use it.
 
  • Like
Reactions: HTalaia

HTalaia

New member
Mar 3, 2012
4
1
Its not meant to be flashed using the stock recovery.

You need a custom recovery to use this script, like TWRP.

Judging by your story, you wont be able to use it.

Thank you for your help.
Well, the next step is trying to install a custom recovery... but seams that it won't be possible... I will keep looking and trying to find solutions.

Thank you once again
 
  • Like
Reactions: christian.arvin

TraderJack

Senior Member
Oct 5, 2008
399
157
Google Pixel 3 XL
Should this work on a Pixel 3 XL?

I'm running twrp but am unable to get this (or any other build.prop flashable I've tried) to work.
I don't get any errors, and in my various tests I'm pretty sure that the file is getting copied and executed, but my build.prop never gets modified.
I think there might be some issue with it mounting the partition to access the file, but I don't get any errors and not sure how to troubleshoot.
Also, no backup is created - yet another reason I think it can't even access the file.

I'm using the "a" version so my tweap.prop is inside the zip.
 
  • Like
Reactions: Koncrete

Miustone

Senior Member
Jul 23, 2012
3,305
6,108
29
Google Pixel 7 Pro
I think this isn't working since system-as-root (or Treble) is a thing. Is anyone aware how we can mount the newer Android Systems the right way? My actual Script looks like that:

JavaScript:
#!/sbin/sh
set -e

VER=V21

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 "M.A.R.S. PROP $VER"

ex() {
 chmod 0644 "$build"
    ui_print "-ERROR: [email protected], SCRIPT ABORTED"
    exit 1
}

build=/system/build.prop
echo "" >> "$build"
name=mars.prop

for part in system data
do
    ui_print "-MOUNTING /$part"
    if mount | grep -q "/$part"
    then
        mount -o rw,remount "/$part" "/$part" && ui_print "-REMOUNTING /$part RW" || ex "-CAN'T WRITE ON /$part"
    else
        mount -o rw "/$part" && ui_print "-/$part MOUNTED RW" || ex "-CAN'T MOUNT /$part"
    fi
done

ui_print "-SETTING PERMISSIONS FOR $build"
chmod 0666 "$build"

ui_print "-INJECTING PROP FILE"
prop=$(find /sdcard* /storage* /ext* /tmp* -name $name -type f -follow 2>/dev/null | sed 1q)

test -s "$prop" && ui_print "-$prop FOUND WITH CONTENT" || ex "-CUSTOM FILE $name NOT FOUND OR EMPTY"

answer=$(sed "s/BACKUP=//p;d" "$prop")

backup() {
    echo "# BACKUP OF $build CREATED AT `date` MARS PROP PATCHER $ver" > "$1" || ex "-CAN'T WRITE BACKUP FILE $1" && \
    (cat "$build" >> "$1" && ui_print "-$build BACKED UP AT $1.")
}

case "$answer" in
y|Y|yes|Yes|YES)
    backup "${prop%/*}/${build##*/}.backup"
    ;;

n|N|no|No|NO)
    ;;

*)
    [[ -z "$answer" || ! -d $(dirname "$answer") ]] && ex "Given path is empty or parent directory does not exist" || backup "$answer"
    ;;
esac

ui_print "-READING $prop"

sed -r '/(^#|^ *$|^BACKUP=)/d;/(.*=.*|^\!|^\@.*\|.*|^\$.*\|.*)/!d' "$prop" | while read line
do
    if echo "$line" | grep -q '^\!'
    then
        entry=$(echo "${line#?}" | sed -e 's/[\/&]/\\&/g')
        grep -q "$entry" "$build" && (sed "/$entry/d" -i "$build" && ui_print "-ALL LINES CONTAINING \"$entry\" REMOVED")

    elif echo "$line" | grep -q '^\@'
    then
        entry=$(echo "${line#?}" | sed -e 's/[\/&]/\\&/g')
        var=$(echo "$entry" | cut -d\| -f1)
        app=$(echo "$entry" | cut -d\| -f2)
        grep -q "$var" "$build" && (sed "s/^$var=.*$/&$app/" -i "$build" && ui_print "-\"$app\" APPENDED TO VALUE OF \"$var\"")

    elif echo "$line" | grep -q '^\$'
    then
        entry=$(echo "${line#?}" | sed -e 's/[\/&]/\\&/g')
        var=$(echo "$entry" | cut -d\| -f1)
        new=$(echo "$entry" | cut -d\| -f2)
        grep -q "$var=" "$build" && (sed "s/^$var=.*$/$var=$new/" -i "$build" && ui_print "-VALUE \"$var\" CHANGED TO \"$new\"")

    else
        var=$(echo "$line" | cut -d= -f1)
        if grep -q "$var" "$build"
        then
            grep -q $(grep "$var" "$prop") "$build" || (sed "s/^$var=.*$/$line/" -i "$build" && ui_print "-VALUE \"$var\" OVERRIDDEN")
        else
            echo "$line" >> "$build" && ui_print "-ENTRY \"$line\" ADDED"
        fi
    fi
done

sed '/^ *$/d' -i "$build"

ui_print "-CLEANING"

chmod 0644 "$build" && ui_print "-ORIGINAL PERMISSION FOR $build RESTORED"

for part in system data
do
    umount "/$part" && ui_print "-/$part UNMOUNTED"
done

ui_print "-DONE"

Thanks in advance for any Help with that!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 103
    Hey,

    since I'm flashing nightlies on a regular basis and also want to use my own custom /system/build.prop file, there are a few ways to accomplish both things as easy as possible:

    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

    For most of you one of these ways should absolutely do the trick, but my problem was either things like build version, date, etc. got stuck at my custom file's one or I had to reboot after manually updating it, which got really annoying after several times.

    So I decided to create my own flashable zip which works as follows:

    Somewhere on the device is a simple text file in which are all those entries that shall be changed,added to or removed from /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
    It This script scans the text file (aborts if not found) and looks for changed, new or unwanted entries in /system/build.prop in order to apply them. Changed entries will be overridden, new ones will be added, unwanted get removed and 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 and unmounts /system and /data (only if they weren't mounted before) and reverts /system/build.prop's permissions to rw-r--r--

    -> (See content of example.txt for more detailed examples and syntax!)

    Using this method, you can not only forget about manually updating versions and/or lame reboots after updates for changes to take effect, but also edit your personal text file at any time without root rights beeing required. Once set up to be flashed after every update, your /system/build.prop is always tweaked as you wish and looks like a stock one (ROM version, etc. under About Phone).

    The zip flashes well on all recoveries. Make sure your tweak.prop file ends with an empty line, otherwise the last line will be ignored!

    I hope some of you can use this zip, it's free to modify. If you have any suggestions, let me know.

    This project has been moved to a git repo at https://notabug.org/kl3/tweakprop. Please refer to it in the future to get updates as this is much easier for me to maintain. Upcoming changelog can be found here.
    20
    Changelog

    Changelog
    version 0.1:

    • 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


    version 0.5.1:


    • lines beginning with ! will be removed globally
    • little code-cleanup


    version 0.5.2
    :


    • lines beginning with @ will append the string after | to values of existent entries
    • slight changes in code structure


    version 0.5.3
    :


    • lines beginning with $ will change the value to the string after | only if the entry already exists, hence $telephony.lteCdmaDevice|1 is nothing but a more explicit approach of telephony.lteCdmaDevice=1, as the first one will only make changes but no new entries


    version 0.5.4
    :


    • the build.prop file can now be backed up before editing using a BACKUP= line, see example.txt for details
    • tiny bug fixed


    version 0.5.4a
    :


    • tweak.prop file (example.txt) is included, no personal file on your device's storage is used. Edit the zip's content before flashing!


    version 0.5.9(a)
    :


    • Error handling fixed, script properly exits now if anything failes and won't make further changes
    • More verbose output
    • Date and tweak.prop version added to backup files to keep track of them
    • Special characters like / are now escaped and handled correctly by sed
    • Slight changes in coding style as it's good practise
    3
    Well, this was way easier than I thought at first glance, so why not supporting xda folks instead of gaming, right? :D

    Version 0.5.3 was released, just a minor syntax case added for fixing problems that might occour when flashing the same tweak.prop file on different devices. See the changelog for more infos!

    As usual:
    55132479.jpg
    3
    Thanks for your great feedback, guys! Finally it should really work, I found some typos inside the sed-commands breaking the syntax. Version 0.5.1 is reuploaded again. :eek:

    If you like my work, please share it, name it in your signature or donate some cents - every support is highly appreciated!

    Maybe an additional app to easily edit your tweak.prop file, toggle adding/removing/overriding lines and apply changes would be nice to have? Would do you think?
    2
    Hi k,

    I remember this was something me and Patrics were playing around with for ROMCleaner before life got in the way :(

    Good work, I love little scripts like this and will be sure to play around with it on my next flash.

    I have some suggestions if thats ok?

    Does the answer file have to have the .prop extension?

    We found it was a lot easier for users to use a standard .txt file rather than 'fiddle' with a different extension.

    I know it sounds like a little thing but you'll be surprised at how many dont...

    Can you make the script ignore anything in the file answer file preceded with a #?

    If so you can make a sample file for complete novice users to use and also have the ability to quickly enable/disable edits.

    Something like:

    Code:
    #   !!!ALWAYS USE NOTEPAD++ WHEN EDITING THIS FILE!!!
    #
    #        ===============================================
    #        |                                             |
    #        |         Dynamic build.prop Editor           |
    #        |                     by                      |
    #        |                 klenamenis                  |
    #        |                                             |
    #        ===============================================
    #
    #        For help and support, please visit my thread:
    #
    #			http://forum.xda-developers.com/showthread.php?t=2664332
    #
    #   !!!ALWAYS USE NOTEPAD++ WHEN EDITING THIS FILE!!!
    #
    #
    #==========================================================================================================================
    #
    #	Add your custom build.prop entries to this file to have them automatically
    #	applied to your current build.prop when flashing a new ROM.
    #
    #	After flashing your ROM flash the tweakprop.zip and edits will be applied.
    #
    #	Eg:
    #
    #	To enable an edit:
    #
    #	ro.sf.lcd_density="400"
    #
    #	To disable an edit, precede the line with a hash symbol (#):
    #
    #	#ro.sf.lcd_density="400"
    #
    #==========================================================================================================================
    #
    #	!!! EDITS GO BELOW !!!
    #
    #==========================================================================================================================

    You could also go more adanced and make the .sh dynamic by having some asserts in the updater-script look for the answer file in predefined locations etc

    You can do a lot with scripts like these, just which I had more knowledge of nix scripting :(