1

I used Texdroider DPI to change the dpi from 320 to 300 and after the reboot it gets stuck at the lenovo logo. I could just flash it again but i don't have the rom on this pc, and it will take 10h to download it.

Is there any faster way to reset the dpi? I have TWRP installed. With android 5.0.1.

Edit: Output of cat /system/build.prop | grep density is ro.sf.lcd_density=300 Tried editing build.prop back to 320 with Sublime Text. Now the command returns ro.sf.lcd_density=320 but it still gets stuck.

user1824034
  • 131
  • 1
  • 2
  • 5
  • 1
    Your Android version and device? Is the USB debugging enabled? Which app did you use? Link it. Boot into TWRP, mount data partition, go to /data/property and confirm us whether persist.sys.lcd_density exists? If it exists, what does it contain? – Firelord Dec 12 '15 at 14:19
  • It's not there. – user1824034 Dec 12 '15 at 14:32
  • Alright, but that does not tell us the Android version you're using. Now, when booted into TWRP, mount system partition, open TWRP's command line and do cat /system/build.prop | grep density. Tell us the result. – Firelord Dec 12 '15 at 14:34
  • # Lenovo-sw wuzb1 2014-10-08 set default density ro.sf.lcd_dencity=300 – user1824034 Dec 12 '15 at 14:42
  • Change the density back to 320 in that file. On a side note, can you use the body of the question to display the output? You should only be getting the line ro.sf.lcd_density in the command's output. – Firelord Dec 12 '15 at 14:44
  • Pull the build.prop file into PC and post the file here. Use a paste service such as pastebin or gist.github. I just want to make sure that my command only changes density and nothing else. – Firelord Dec 12 '15 at 14:47
  • The app's description says "replace /system/build.prop with /data/data/com.texdroider.texdroider_dpi/files/backup/build.prop using adb, or restore a rom backup" -- have you tried it? Are you certain that while editing the file, you didn't add any new character next to 320, be it deliberately or inadvertently? It could be a whitespace too. – Firelord Dec 12 '15 at 15:16
  • I'm sure, yeah. Just did cp /data/data/com.texdroider.texdroider_dpi/files/backup/build.prop /system/build.prop and the file does not exist. The directory com.texdroider.texdroider_dpi appears like a file in the explorer. – user1824034 Dec 12 '15 at 15:24
  • I see. The app didn't make any backup but expected user to make backup, so that's why you don't have one. Just last thing I would ask to do: can you execute the command adb shell sed -i -e 's/.*ro.sf.lcd_density.*/ro.sf.lcd_density=320/g' /system/build.prop? If you're not using a *nix system, you would need sed editor installed in system. – Firelord Dec 12 '15 at 15:32
  • I'm on windows, and have no idea how to run this... Tried it on twrp and it says cannot link executable: could not load library libc.so needed by adb[...] is 32-bit instead of 64-bit. – user1824034 Dec 12 '15 at 15:43
  • If you want to run the command on TWRP, do sed -i -e 's/.*ro.sf.lcd_density.*/ro.sf.lcd_density=320/g' /system/build.prop or put it simply, remove adb shell from the earlier command. Make sure system partition is already mounted. – Firelord Dec 12 '15 at 15:44
  • Still nothing.. – user1824034 Dec 12 '15 at 15:57
  • There is one more thing you can try. Boot into TWRP, mount data partition, use PC to execute adb shell busybox printf "320" > /data/property/persist.sys.lcd_density and then adb shell chmod 600 /data/property/persist.sys.lcd_density. Unmount data partition, reboot into Android and tell us the result. – Firelord Dec 14 '15 at 11:14
  • 1
    Thank you so much for trying to help, but I ended up flashing it. – user1824034 Dec 14 '15 at 14:28

2 Answers2

1

Note:

  • Parts of this answer didn't work for OP, but nevertheless, they worked in all of my test cases with different ROMs, hence, the answer would certainly prove to be useful for some users.
  • Device should have a custom recovery installed.
  • should be setup in PC and USB debugging be enabled and authorized in the device.
  • Anything mentioned next to # anywhere in a line is a comment.

More or less, the changed DPI value would either be in settings.db, /data/property/persist.sys.lcd_density, /system/build.prop or in memory only. I've covered instructions for all of these cases and they should prove to be helpful when the device gets stuck at boot animation.

  • If it is an Xposed module which changed the DPI and caused boot issue, then try disabling the module or the framework, or, remove the former or both. See my answer here for more info on that.

  • If you used command-line to change DPI (am/wm), then when the device gets stuck at boot animation (past the OEM logo), execute

    adb shell am display-density reset    # For Android 4.2.x
    adb shell wm density reset            # For Android 4.3.x and above
    adb reboot
    
  • In my Android 4.2.1, custom display density is saved as a value for the key display_density_forced in the table global of /data/data/com.android.providers.settings/databases/settings.db. If you've used command-line (am) or an app used this key, follow these steps:

    • When booted into recovery, mount data partition, pull the said file into PC and use an sqlite editor to either remove the key or change the value to a better or default DPI. After that, push the file back to its place.

      adb pull /data/data/com.android.providers.settings/databases/settings.db LOCAL_PATH     # to pull the file into PC
      adb push LOCAL_PATH/settings.db /data/data/com.android.providers.settings/databases/    # to push the file into Android
      adb reboot 
      

      Replace LOCAL_PATH with the directory under which settings.db is to be saved and is saved, respectively.

    In Android 4.3 and above, custom display density can be found under /data/property/persist.sys.lcd_density or by executing adb shell "getprop | grep density". If you used command line (wm) or an app used that property to change DPI then follow these steps:

    • When booted into recovery, mount data partition and do

      adb shell rm /data/property/persist.sys.lcd_density                      # this will cause Android to fall back to default DPI
      adb shell busybox printf "DPI" > /data/property/persist.sys.lcd_density  # change DPI with your custom DPI value
      adb reboot
      
  • Finally, the easiest but a dangerous and extreme approach you or an app would take is to change the DPI for the key ro.sf.lcd_density inside /system/build.prop. The DPI in the said file is considered the stock DPI of that ROM.

    When booted into recovery with data partition mounted,

    • You can choose to override the stock DPI by doing

      # replace DPI with your custom DPI
      adb shell am display-density DPI   # For Android 4.2.x only 
      adb shell wm density DPI           # For Android 4.3.x and above only 
      adb reboot
      
    • If that doesn't work for some reason, do

      adb shell sed -i 's/.*ro.sf.lcd_density.*/ro.sf.lcd_density=DPI/g' /system/build.prop      # sed is replacing the DPI with your custom DPI value
      adb reboot
      
    • If none of the solutions work then your only option is to replace build.prop. If you've a clean backup of system partition or build.prop then use it to replace original file, else flash the ROM as OP did.

Note: I personally did not test, but it has come to my notice to not edit any file of Android using any native text editor of Microsoft Windows OS. Instead, use Notepad++ or altogether do all the editing using command line in recovery.

Firelord
  • 25,084
  • 20
  • 124
  • 286
1

This is a small updated answer since android no longer stores one single settings database & editing build.props doesn't seem to work on a number of newer phones. Also "shell wm" commands don't work on twrp recovery.

At least in my case (xiaomi Redmi9 with android10) settings are stored in:

/data/system/users/0 

These are the 2 values that need to be edited:

"display_size_forced" in settings_global.xml
"display_density_forced" in settings_secure.xml

You need a custom recovery installed and a way to edit the files, either on your PC or directly on the recovery by using Nano Editor. Once done just reboot and that's it!

You don't need the exact values for resolution or density just something close enough to be able to boot, then reset to the devices default by using ADB.

I hope this helps anyone stuck in recovery boot after editing dpi or resolution.

Dr.
  • 11
  • 1