Rooting and custom ROM for Android
www.hackoooo.blogspot.in
As discussed earlier, even though Android is supposed to be Open Source,
users don’t always have access to all of the phone’s features or can’t modify
the phone in an arbitrary way. One of the (if not the most) popular starting
points for Android customization is to ‘root’ your phone. Rooting gives the
user access to a plethora of tweaks and powerful customizations include the
ability to tether your phone’s internet connection via Wi-Fi, overclocking
your phone’s CPU, backing up your apps or installing ad-blockers. But
what exactly is rooting and what do you, as a user stand to gain from the
process? Let’s find out!
28 rooting and custom roms for android
What is rooting?
Rooting a phone is Android-speak for gaining administrator-level priveleges
to the phone. Typically, users don’t have access to a phone’s higher level
files and folders and can only deal with files and directories stored on the
phone’s external memory or SD card. The system critical files, processes
and applications like the dialer, messaging and camera apps reside in the
phone’s internal memory. Users can’t uninstall these apps, nor can they
directly make changes to the filesystem. This is where rooting comes in. By
rooting one’s phone, the user is granted elevated priveleges and can make
modifications to any file or applications located anywhere on the filesystem.
As a crude analogy, consider your desktop computer running Windows
– Your ‘Windows’ folder (typically located under C:\Windows) contains
system files which are critical to the system. Not having root priveleges
on an Android device is analogous to not being able to edit the contents of
this Windows folder. Rooting one’s device would be similar to ‘unlocking’
the contents of the Windows folder and being granted the ability to add,
remove or edit files at your will. While this may not seem like a big deal
(As most of us don’t interact directly with our Windows folders) there are
severa apps that can take advantage of this ability, resulting in greater functionality
for your device. (This analogy has several inaccuracies, least of all
that Windows uses a very different filesystem structure than Android and
other UNIX-based systems, which use a top-down or tree-like hierarchy.)
The term ‘root’ is a feature of UNIX and UNIX-based systems which use
a tree-like filesystem structure. The top level directory is designated with
a ‘/’ and is called root. Having access to files at this level of the hierarchy is
having ‘root’ access to the system, and a user having root access is a root
user (or superuser). Since Android uses a Linux kernel, and Linux itself is
derived from UNIX, the terminology carries on.
How does the rooting process work?
In order to understand how rooting occurs, we need some insight into the
Android system.
Most devices, by default have their /system partition (found in the
device’s internal memory) set to read-only, which means apps cannot modify
this sacred folder. Mounting the /system partition with read-write access
requires root priveleges. In an Android system, only a priveleged app
(i.e. An app running as root) can invoke or start another priveleged app.
Ordinary apps that are run as user cannot start apps that need priveleged
rooting and custom roms for android 29
access. This is a security measure, for in its absence any app would have
been able to invoke itself (essentially creating a copy itself) with elevated
priveleges. Hence, for an app to run as root, it must request root priveleges
from an external app, called the Superuser or simply ‘su’. The final aim of
the rooting process is to install this Superuser app on the device’s internal
memory as a system app. Any app that needs elevated priveleges (a.k.a.
root access) can then request the same from the Superuser app, a request
which is usually forwaded to the user.
When an Android system boots up, the first piece of code that is executed
is called the bootloader. This bootloader controls the boot process, hence
access to the bootloader is required when installing a custom ROM or
aftermarket firmware. Many devices, however, come with a ‘locked’ bootloader
and need to be worked upon (read: hacked into) before we can flash
a custom ROM. However, if a device has an unlocked bootloader, rooting a
phone becomes relatively easy. One can either find a custom ROM for your
phone model that has already been rooted and flash it onto your phone, or
you can simply pull the existing ROM from your device, add the Superuser.
apk file to it and flash it back to your device.
Another nifty utility that Android provides is the Android Debug Bridge,
better known as the ADB. The ADB allows you to execute commands entered
via a computer on your Android device, essentially allowing you to VNC
into your device. Any command executed on the adb shell while the phone
is connected to the computer will be exectued on the device. Some devices
have a feature, where any command issue via the ADB is automaticaly given
Superuser acess. In this case, installing the Superuser app permanently
is as simple as plugging in the phone, starting the adb and issuing the
commands to copy the file to the device. The ability to execute ADB shell
commands as root depends on the value of a configuration key (analogous
to a registry key in Windows) called ro.secure whose value can be either 1
or 0. A value of 0 implies that the system will execute all commands as root
user, whereas a value of 1 means apps will run with unpriveleged rights.
You can check the ability of your shell by entering getptop ro.secure into
your device, either through a terminal emulator or the ADB.
Finally, in the event that both the bootloader and the ADB are locked,
how does one go about rooting one’s phone? This is done using vulnerabilities
in low level system processes that have root access in order to interact
with the device’s hardware components. During the boot process, after the
Linux kernel has been loaded into the memory, the init process is started
30 Rooting and custom ROMs for Android
(‘spawned’) by it. This init process has root priveleges
as it is required to start other priveleged
processes and services that are critical to the
functioning of the device. Thus, during normal
operation of an Android device, there exist background
processes running as root. The key lies in
being able to trick these processes into executing
some code that will mount the /system partition
as writeable, as well as permanently install the
Superuser application. Most popular rooting
methods use this technique. After the device has
been rooted, any app that claims to require root
access will basically try to start other priveleged
apps (often bundled within the same app) using
the su or Superuser app. When it tries to start su, the user is asked to grant
or deny priveleged access to the app.
How do I root my Android device?
Android devices differ in many aspects, including the form factor, screen
size, hardware features and most importantly, the build of Android they’re
currently running. The sheer variety in the exploits used to root a phone
means that no single method is applicable to all devices running Android.
The rooting procedure itself is a very simple one, and most methods require
to either connect the phone to the computer and use a tool, which, with
the press of a single button will root your device for you. There also exist
methods where users don’t need a computer, simply downloading an app
and running the app should do the trick.
Some popular methods for rooting which apply to a large number of
devices are Unlock Root, Gingerbreak, SuperOneClick and Universal Androot.
However, if you wish to root your device, your best bet would be to
look for a rooting method that has been tested to work on the same device
running the same version of Android. This is because rooting methods
differ from device to device and even between different versions of Android.
There is really no ‘one size fits all’ technique for rooting.
One important thing to keep in mind is that rooting a phone qualifies
as tampering with the phone’s internal software, and this will, in most
cases nullify the warranty on your device. There is also a slight risk of
something going wrong and the phone becoming unusable. This doesn’t
The Superuser app grants
root permissions to apps
Rooting and custom ROMs for Android 31
usually happen, but to be on the safer side, it is highly recommended that
you backup all of your phone’s data including your contacts, messages and
applications (along with application data). Contacts are usually backed
up by Google within your Gmail account, but if you want to be extra sure,
you can export your contacts as a .vcf file to your SD card. This backup can
be moved to a safe location and can be used to restore your contacts by
importing your contacts from this file. Messages can be backed up using
SMS Backup and Restore, which exports your messages along with their
metadata to an .xml file on your SD card. Applications can be backed up
using ES file explorer or Astro file manager.
Why should I root my phone?
As discussed before, rooting unleashes the full potential of your phone giving
you features from apps that were earlier unavailable. Apps can interact with
much more advanced aspects of your phone, giving you almost limitless
control over your device. As an example, we’ve listed the top 10 hacks you
can use to gain control of your rooted phone. Naturally, all these hacks
require you to be rooted with the Superuser binary installed.
1. C ontrol your CPU
Modern smartphones come with powerful
CPUs with clock speeds in GHz and advanced
frequency scaling features. Apps like SetCPU
can change the scaling limits of your phone,
allowing you to overclock it for better performance,
or to underclock it to save battery
life. Bear in mind though, that this is a highly
risky task, and changing the parameters outside
the device’s limits could be disastrous.
2. S ecurely backup apps/ move
apps to SD card
Apps like Titanium Backup / ROM Toolbox
let you create secure backups of your apps
along with their data to your SD card. Titanium Backup can even export
your backups to the cloud via your Dropbox or Box account. These apps
also let you forcibly move apps from the phone’s internal memory to
the external (SD card) memory, a handy feature for lower-end devices.
Overclock your CPU with
SetCPU
32 Rooting and custom ROMs for Android
Titanium Backup has a few additional
features like the ability to freeze apps
or forcibly attach sideloaded apps to the
Google Play Store.
3. U se an ad-blocker to block ads
Ever downloaded a really engaging app
only to find that it displays annoying ads
while you use it? The constant polling by
the app has been shown to consume a large
amount of battery. Ad-Away and Ad-Free
are root apps that modify the hosts file
located in /etc/hosts and block most (if
not all) ads for you.
4. T urn your phone into a portable
Wi-Fi hotspot
This is a handy feature for phones with
a data plan. If you ever find yourself
without an internet connection for your
laptop/tablet and can’t find a data cable for
your phone, you can tether your phone’s
internet connection
by
turning your
phone into
Wi-Fi hotpost.
The network
will show up on your other Wi-Fi enabled
devices like a regular wireless network.
5. Extend your phone’s battery life
Smartphones are notorious for their poor battery
life and it’s not uncommon to have to
charge your phone for a few hours everyday.
Juice Defender can optimize your phone’s battery
life by creating profiles and turning on/
off power-hungry settings when not in use. It
Titanium Backup can securely
backup your apps and data
Block those annoying ads within
your apps with Adaway
Wireless Tether can turn your
rooted Android phone into a
portable Wifi hotspot
Rooting and custom ROMs for Android 33
can turn off your Wi-Fi/Cellular
Data when the screen is turned
off, or for a designated time of
the day, or turn off the brightness
and disable your GPS/Wifi
radios when you’re phone is running
low on battery.
6. Backup or flash a
new ROM
This is one of the most compelling
reasons to root one’s device,
and ROM Manager is one of the
most commonly used apps to
manage your device’s firmware
image or ‘ROM’. It can enable
you to backup your complete
system image and flash new
custom versions of ROMs.
7. Browse the contents of
your entire phone
Root Explorer and ES File Manager are file managers that let you browse
and edit the contents of your phone’s filesystem all the way down to the
root level. You can move files around and even remove the bloatware
that came pre-installed on your phone.
8. S et up a Samba share
If your and phone and computer are on the same wireless network, you
can share your phone’s contents in the form of a Windows Share using
Samba Share. Once set up, your phone will show up as a network device
in Windows. Samba shares can also be set up on Linux/ OS X machines.
9. Enable region-specific apps from the Google Play store
Many apps on the Play store are region specific and aren’t available to
users from other regions. The Google Play Store is not available in many
countries, which puts them at a huge disadvantage. The Market-Enabler
is an app that can mask your phone’s location and make available to
ROM Manager is an app that can install
Clockworkmod recovery or flash a custom
ROM for you
34 Rooting and custom ROMs for Android
you the hundreds of thousands of apps that
populate the Play Store.
10. Use virtual buttons/swipe
gestures for back/menu/home
If your phone has hardware buttons for home/
menu and back, chances are these buttons
might wear out over time and eventually stop
functioning. Button Saviour, Virtual button
Bar and Zmooth Root are apps that allow you
to use on-screen equivalents of your phone’s
hardware buttons and also ads some intuitive
swipe gestures for back/menu and home.
Why shouldn’t I root
my phone?
Like we’ve said before, rooting will almost certainly
void your device’s warranty, and any
damage that might occur to your phone during
or after the rooting process will not be covered
under the warranty. This is purely a statutory
warning though, most modern rooting methods
are quite safe and cases of phones being ‘bricked’
while rooting are highly rare. Nevertheless, rooting is not for the faint at
heart, and some root applications like SetCPU if misused, can wreck havoc
on your phone’s internals and cause irreparable damage to the device. There
is, however, some consolation in the fact that one can usually reverse the
process and un-root a device, making it almost impossible to detect if it had
been rooted earlier.
Custom ROMs in Android
While rooting certainly extends your device’s capabilities to a large extent,
your device is capable of a lot more. Instead of simply accessorizing your
phone, why not give it a completely new wardrobe? For Android geeks,
flashing a new firmware onto their devices is the ultimate exercise in customizing
one’s Android experience. So just what is a custom ROM, why
would one want to install (or ‘flash’) a new ROM onto his device and how
does one go about the process? We’re here to show you.
Note
You do NOT need to
be rooted in order to
sideload applications
on your Android
device. Just check
the ‘Install from Unknown
Sources’ option
under Settings >
Applications. Any application
in the form
of a valid .apk file can
be installed on your
device by copying the
file into your phone’s
external storage,
navigating to the file
using a file manager
and selecting the
.apk file.
Rooting and custom ROMs for Android 35
In computer technology, a ROM
stands for Read Only Memory, a
section of memory that cannot be
written into, and stores important
firmware that is read from during
the boot process. However, in the
Android community, the meaning
of a ROM is quite different, and the
term is used to refer to the image
of the OS that your phone runs.
These ‘images’ are all based on the
original (or ‘stock’) Android system
provided and open sourced by
Google. Different developers add (or
sometimes remove) components to
tweak the performance of the device
running Android. Android ROMs
are treasured by the community
as they unlock features previously
locked down by the manufacturer
(or at times, the wireless carrier),
remove crapware installed by OEMs and provide significant performance
enhancements, giving a new lease of life to older devices. The process of
installing an Android ROM is called ‘flashing’, and will in most cases void
your warranty. Needless to say, one needs to exercise caution in attempting
to flash a ROM. If done correctly though, a custom ROM can make using
your device a joyride.
Custom ROMs for Android, as you might’ve guessed are a dime a dozen.
There exist literally hundreds of ROMs, each boasting of a particular feature
such as a lower system footprint, added features and apps, better aesthetics
in the UI, or a mixture of all three. These are analogous to Linux distributions,
where the ability to openly modify and redistribute the source code
has resulted in a number of flavours of Linux. Two of the most popular
ROMs are Cyanogenmod and MIUI, where the former focuses on speed and
featured, the latter sports a gorgeous interface and some beautiful stock apps.
Due to the wide range of devices with different internal hardware and
screen sizes, there is no universal firmware when it comes to Android.
ROMs are always catered to specific device models, and you can seri-
Cyanogenmod lets you easily tweak your
phone
36 Rooting and custom ROMs for Android
ously damage your phone if you
try to flash a ROM that isn’t targeted
for your device. Having said
that, the vast community support
that Android enjoys means
nearly every device out there
has a alternative firmware for
it, but if there isn’t one available
for your device, you can request
your favourite ROM’s developer
for a port. While the exact procedure
for flashing ROM varies
from one ROM to another and
even between devices, the generic
method is somewhat like:
DISCLAIMER: These steps are
generic and are only meant to be indicative
in nature, to give readers an idea
of what the flashing process is like. They
are by no means a complete guide on
how to go about installing a new ROM
for your device. For installation guides,
please refer to the wiki for each ROM’s
website. All popular ROMs will provide elaborate installation guides for all supported
devices, as the process varies from device to device. It is infeasible to give a detailed
guide covering every device and ROM out there.
1. Backup your apps, contacts, settings and messages.
2. Obtain the ROM’s firmware in a .zip file and store it in the root of your
SD card.
3. Use ROM Manager, an app from the Google Play Store to flash Clockworkmod
recovery, an alternative ‘recovery’ for your device. (The
recovery partition has been discussed in an earlier section). Your phone
needs to be rooted in order to do this.
4. Reboot your phone into recovery mode using the option in ROM Manager.
Devices also come with a specific key combination for this purpose,
but if you’re unsure (and don’t want to risk damaging your phone’s
hardware buttons) we recommend you use this option.
MIUI ROM focuses on aesthetics, and is one
of the most beatiful ROMS around
Rooting and custom ROMs for Android 37
5. Choose the ‘update from zip file’ option
and select the firmware file that you had
earlier copied into the SD card.
Some phones (like HTC’s newer devices)
come with locked bootloaders than prevent
you from installing a third-party firmware.
There are tools available (HTC provides an
official tool to unlock the bootloader) to circumvent
this issue, though the process may
not always be straightforward. Find out if
your phone comes with any such restrictions
before you begin the flashing process.
If you’re running a rooted Android device,
make sure you take a complete backup of
your ROM using Clockworkmod’s Backup
and Restore feature. Furthermore, developers
usually make a list of all the fully working features as well as bugs
in the build, read it and make sure that the ROM is stable enough for
everyday use.
Android is truly a hacker’s dream, for it provides almost endless potential
to tweak and mod your device to your heart’s content. You can improve
existing features, add new ones or remove ones you don’t need, and truly
customize your mobile experience provided you know what you’re getting
into. Having said that, hacking into one’s Android device is not a necessity
– Android is a highly advanced platform with plenty of features right out
of the box, along with a plethora of apps to try out from the Google Play
Store. However if you’re someone who’s not content with ‘good-enough’
and is looking to extend your phone’s functionality, Android should be
your platform of choice.
0 comments:
Post a Comment