Reader small image

You're reading from  Learning Embedded Android N Programming

Product typeBook
Published inJul 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785282881
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Ivan Morgillo
Ivan Morgillo
author image
Ivan Morgillo

Ivan Morgillo is a computer engineer, a conference speaker, and a community organizer. He is passionate about programming and embedded systemsfrom DIY domotics to Android devices. He is cofounder of Alter Ego Solutions, a mobile development consulting company. He is also the author of RxJava Essentials, by Packt Publishing and Grokking Rx, by Manning Publications.
Read more about Ivan Morgillo

Right arrow

Chapter 7. Tailoring Your Personal Android System

In the previous chapter, you learned about the most popular custom Android ROMs. We started to dive deep and analyze those parts of the system involved in the modding process, to effectively understand where to customize and how to do it, mastering the Android modding toolset.

In this chapter, we will go even further, diving deeper into every single aspect of a ROM, using practical examples to show how to customize and increase the performance of your ROM.

The main topics of this chapter are:

  • Hacking the Android framework

  • Adding new Android applications to the build system

  • Adding new Linux-native apps, using the Android source code, or editing an existing binary ROM image

  • Optimizing the system to better support custom hardware, with focus on the application layer and on the kernel layer.

Receiving over the air updates – OTA


Every Android device is, by design, able to receive updates over time. These can be system updates—when a new Android version has been released, or security updates—when some critical vulnerability has been fixed and Google is distributing the patch. Once the update has been received, every device is able to decompress and apply this update, following the required procedure.

These types of updates are called OTA, or over the air updates, because they can be downloaded and applied by the Android device itself, without the support of a host PC. These updates are typically going to patch operating system features, working in the so-called read-only part of the system. No user app will ever be affected by these updates— apps installed via the Google Play Store are completely safe.

Android will asynchronously notify you when a new OTA is available. Most of the time you will receive a notification if connected to a Wi-Fi network and if your battery is above 50...

Creating over the air updates


Google provided plenty of developer tools to generate the different types of OTA. If you want to generate a Full Update OTA, the following two steps are required:

  1. Generate a ZIP file containing the full update files

  2. Generate the OTA package with all the necessary toolsets for the update

To generate the zip file containing the chosen target files, navigate to the root folder of the AOSP sources and run the following commands:

. build/envsetup.sh && lunch aosp-shamu
mkdir dist_output
make dist DIST_DIR=dist_output

If the process has been successful, we should have the zip file containing the target files in the directory dist_output. As an example, let's try listing the folder content with the following command:

ls -l dist_output/*target_files*

Now we should see a .zip file that will also have in its name the name of the target we are compiling for.

At this point, you only need to generate the OTA package containing all the necessary files for the update....

Advanced ROM customization


In the previous chapters, you have made your first steps within the custom ROMs world; we have discovered what's already available online and analyzed the most characteristic aspects in detail. In this chapter we will go in deep and learn how to modify the most internal parts of Android's framework.

Custom ROMs are often associated with those "hackers" who add the most unexpected features and then share everything online, but it doesn't always happen like that.

As explained in the previous chapters, many device manufacturers propose their own modified Android version, which is nothing but an Android custom ROM.

This is a very important aspect, as this book is addressed both to the previously mentioned hackers and to those who use all this knowledge in their daily work—a hacker will often work with binary ROM, and rarely with sources, while the professional will certainly have the sources at their disposal, as well as all the relevant tools to make the development...

Hacking the Android framework


In Chapter 6, "Cooking" Your First ROM, we had a look at a few heavily-customized versions of Android, and lots of these customizations were related to the User Interface. UI customization is a tricky topic due to the personal taste factor involved: many users love a "pure Android" UI, many other users love the idea of a "different Android" UI, far from the mainstream UI experience.

In this section, we are giving you free will and the chance to choose between a vanilla Android and a customized one. You will learn how to make small customizations, to the status bar or to the colors, for example, or big customizations, like adding a new item to the Settings menu to properly set up the custom features of your custom ROM.

Customizing the boot sequence UI

The graphical appearance of the ¾¦+ boot sequence is definitely one of the most popular customizations you'd like to do and often the one that your users will ask for and will love.

During the boot sequence, a standard...

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...

Advanced Linux kernel modding


When you think about customizing the core of an Android system, you immediately think about customizing the Linux kernel. It manages CPU, sensors, radio, and display, and it's the starting point of every great system customization. As we already saw, modifying the kernel is no easy job, but with the right mindset, knowledge, and toolset, it can be a satisfying experience.

Every embedded system has its own customization possibilities and, when it comes to Android, most of the effort is focused on customizing the following:

  • Governors

  • I/O schedulers

  • CPU overclocking/underclocking

Diving into CPU frequency management

In Chapter 5, Customizing Kernel and Boot Sequence, we had an overview about governors, how they work, and how you can pick a different one for different scenarios. In this section, you will learn how to customize existing governors and how to add new ones to your systems.

Note

A governor, or CPU frequency manager, describes how the CPU behaves, based on specific...

Looking forward


During the writing of this book, we were lucky enough to have a look at the upcoming Android N. The new version will probably be available at the end of 2016 as a stable release, after a few months of public developer preview.

Android N introduces a few interesting features, like the "Multi-Window" mode shown in the next image:

At Google, they are very focused on user feedback, and they decided to introduce this feature into the official version after a few months of testing by Samsung. Most of us will recognize the Multi-Windows mode from the already-available Android ROM, by Samsung. In Android N, this will be available for everybody, on every Android device, with full support for both orientations, portrait and landscape, and even the possibility to resize the split windows by dragging the "separator line".

According to lots of blog posts, one of the most popular categories for Google Play Store apps is Caller ID filters. With Android N, this feature will be already available...

Summary


In this chapter you learned how to effectively customize Android at different levels, following real-world examples. You now know how to programmatically create a custom ROM from source code, preparing a customized folder structure with every piece in place, ready to be assembled by Android's build system. You also know how to approach the customization task if you have an already-assembled system image, and how to customize and reassemble a binary image.

The next chapter will bring you outside the pure smartphone experience and will show you how Android is effectively becoming ubiquitous in our lives: Internet of Things, Android Auto and Android Wear, domotics, and entertainment are just a few of the scenarios in which we can currently find the green droid.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Embedded Android N Programming
Published in: Jul 2016Publisher: PacktISBN-13: 9781785282881
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime

Author (1)

author image
Ivan Morgillo

Ivan Morgillo is a computer engineer, a conference speaker, and a community organizer. He is passionate about programming and embedded systemsfrom DIY domotics to Android devices. He is cofounder of Alter Ego Solutions, a mobile development consulting company. He is also the author of RxJava Essentials, by Packt Publishing and Grokking Rx, by Manning Publications.
Read more about Ivan Morgillo