Sunday, June 4, 2017

Customizing / Changing Android DPI settings

There are multiple ways in which the Android DPI Settings and other window manager settings can be changed.One common method is to use the wm helper, for example:
wm density 160

Another common method is to modify dpi settings using the prop file (/system/build.prop). This is mostly done by adding/modifying the following line
ro.sf.lcd_density=160

in the build.prop file by editing it via fastboot, root, or helper apps.

Both these have limitations, the first method may not work on all platforms and the second method doesn't work in newer android verified boot (verity).

Given that the first method is preferable, because of its 'setting' kind of behavior and doesn't touch unnecessary system files. I am writing about a method of directly modifying the settings database to achieve the same result. There are many such android settings that can be edited / modified similarly. In any case, wm and similar tools help with editing the settings.

The file that we are interested in is:
/data/data/com.android.providers.settings/databases/settings.db

Pull this with various tools like fastboot. If Android is booted, one might need it rooted to access this file. [ Articles like How to Copy Files Over to your Android In a Bootloop with No OS using ADB! and The Most Useful Things You Can Do with ADB and Fastboot on Android might help for this ]

Insert / Update the dpi in settings - for this we'll use sqlite3. 'global' is the table that we are interested there, since this is part of the global settings in android.

sqlite3 settings.db
insert or replace into global values(null, 'display_density_forced', 160);
.quit

Push the file to the same location where we picked it from and we are done.





No comments: