Enhancing the system performance

Lots of the custom ROMs that you can find on the Net bring performance enhancements, extended battery life, and lots of small tweaks. Most of these enhancements can be achieved with a surgical tuning of the build.prop file.

Customizing the system property file

The Android build.prop file contains details about a variety of system settings that are applied to the system during the boot sequence. Before diving into its customization, we need an overview about its internal structure.

Open a terminal and connect to your device using the following command:

:$ adb shell

Navigate to the /system folder and open the build.prop file. The content will look like the following snippet:

ro.product.model=Nexus 6
ro.product.brand=google
ro.product.name=shamu
ro.product.device=shamu
ro.product.board=shamu
[…]

As you can guess, parts of these instructions are specific for every device, but a few of them are quite common. We surely have device model name, brand, codename for product, device and board, and so on.

Some of these common values can be easily edited to obtain interesting behavioral changes in our system. For instance, you have probably noticed the tiny, but perceivable, delay that happens right before the smartphone starts ringing, when you receive a phone call. That delay can be removed by editing just a few lines in the build.prop file. Scan the file and look for these two lines:

ro.telephony.call_ring.delay=0
ring.delay=0

Simply replace whatever value is assigned to them with a nice 0 (zero) and you can say goodbye to the delay.

Ever wondered why you cannot rotate the screen when the phone is displaying the lock screen or the application launcher? No more wondering. Look for these two lines and replace the existing properties with the new one:

log.tag.launcher_force_rotate=VERBOSE
lockscreen.rot_override=true

Do you want to rotate your device more than 180 degrees? Enable a 270 degree rotation with the following line:

windowsmgr.support_rotation_270=true

Another UI trick we can achieve with a single line edit is changing the LCD density value. Search for the following line:

ro.sf.lcd_density=XXX

Replace XXX with the value you want to try. Changing this value will produce a resizing of the system icons and an increase of the screen space: the smaller the value you set, the bigger the amount of free space you get. Unfortunately, there is no exact science here and a little trial-and-error is inevitable, so try to experiment with a few values until you find your preferred setup.

Android devices are getting more powerful every day, but, back in the day, the available CPU power was very limited. To guarantee satisfactory performance and user experience, Android used smart tweaks, like the next one:

ro.media.enc.jpeg.quality=xxx

The previous value alters the rendering quality of JPEG files. Even if it was useful in the past, we can consider it unnecessary on last generation smartphones, and we can safely set it to 100 and enjoy images at 100% of their original quality.

If your smartphone has physical navigation buttons, you can increase screen estate, removing the navigation softkeys at the bottom of the screen by setting the next property as follows:

qemu.hw.mainkeys=1

If your device has no physical key, you can still remove the softkeys and use gesture to navigate; check out the Google Play Store for gesture apps, like All in one Gestures. Continuing on the "screen estate" topic, you can remove the debug mode icon in the system notification bar with the following property:

persist.adb.notify=0

These last two tweaks refer to networking settings. The first one is as follows:

wifi.supplicant_scan_interval=300

This line configures how many seconds will be between every automatic Wi-Fi scan. Android performs automatic Wi-Fi scans by default, looking for an open network to connect or just to increase the precision of the navigation system. You can increase or decrease the frequency of these scans, trying to achieve the perfect balance between a higher precision of navigation and a longer battery life. The second networking tweak gives you the opportunity to set a default DNS server:

net.dns1=8.8.8.8
net.dns2=8.8.4.4

This is extremely useful in countries in which the government filters Internet websites according to their IP addresses. Using the DNS IPs shown in the previous snippet, Google's DNS servers, you will be able to bypass this kind of censorship.

Adding a custom init sequence

Linux legacy is still strong in a few key aspects of the Android architecture. One of the most interesting ones is the possibility to execute custom scripts during initialization time. If you are familiar with Linux systems, you know about the /etc/init.d folder. This system folder contains a collection of scripts that can be executed during system startup. To achieve the same behavior on Android, we can use busybox and its run-parts utility. This utility takes a folder as an argument and executes every script contained in this folder. For instance, the following command will execute every script contained in the /system/etc/init.d folder:

run-parts /system/etc/init.d

To properly copy Linux init.d behavior, we want to be able to execute the scripts in a rigorous order. You can achieve this with clever file naming. Just rename your scripts and prepend a number, like in the following example:

01settings
02optimizations

In the previous example, the 01settings script will be executed before the 02optinimations script, and so on. Now that you have a collection of ordered scripts and you know how to execute them one by one, you need to edit the install-recovery.sh file we saw in the previous chapters and add the following line:

run-parts /system/etc/init.d
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.116.146