Basic Android topic (Guide for Noobs)


Basic of Unix-like systems (ROOT)

  • su, root, rooting, superuser app - what is it, why we need it
  • sh, bash, user/root shell - what is bash, sh; what is user shell; what is root shell; how I can recognise it each other 
  • Bussybox - what is BusyBox, basic list of commands from BusyBox


 Android platform tools

  • adb shell - what is it, for what it is
  • Android SDK - what is it, tool which provides, where to download
  • Tools for work with Android, adb shell - Terminal Emulator, ADB shell from Android SDK and how to use it


Custom recovery

What is custom recovery - what custom recovery is
Tools which custom recovery provides - list of tools with description which custom recovery bringin:
  • ADB as root user
  • USB-MS Toggle
  • Backup/Restore
  • Flash ZIP from sdcard
  • Wipe menu
  • Partition sdcard + etx2, ext3, ext4 filesystem description
  • Mounts
  • Others
Is it save to install? - possible problems, why should I try it?, backup/restore of original recovery


Custom ROM

  • What custom ROM is?
  • Is it save to install custom ROM? - potential problems
  • What I need for install?
  • What can custom ROM brings - kernel, update, performance, customization, theme, ....
  • what is ...
    • deodexed, zipaglined, png-optimized
    • JIT, HW:acceleration, VM.Heap Size, stagefright
    • apps2sd + dalvik2sd
    • custom kernel (recompiled, ...)



Basic of Unix-like systems (ROOT)

Also referred as substitute user - is command for changing of the account in current terminal (usually black screen with blinking cursor). Default account is root account. So if you insert into terminal 'su' and hit enter, you will become root user.

Root alias superuser or poweruser is special user account for system administration. Similar to windows having its administrator account, unix-like system have system have the root. With this user you can do anything and if you will run command for delete whole system, unix will just do it! No asking, no confirming. So, watch your steps!

Rooting is just enabling power of root for applications or our proposes. You can read great article about Rooting on androidpolice.

Superuser app
After rooting is done, you will see new app called superuser in app drawer. This app can delegate applications to use su (root) feature. When app ask for first use, popup window will appear asking if the application should be allowed to use root permission.

sh, bash
is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems. So simply, it is some interface, which can execute command(s), which you have entered. Many shells exist, but in scope of android you can (as far as I know) use only sh (standard - Bourne-shell) or bash (compiled in BusyBox or separately on XDA). Both are basically same, but bash has much more future and it is comfortable. It's too big to describe here, so if you are interested in learning more, follow links in sources section.

user/root shell

How do I know if I'm root or normal user? It's simple. Root's shell is ended with # (usually it's shell looks like "bash-3.2# _") and user's ends with $ (usually bash-3.2$ _). In terminal emulator you also can have only [path]($|#) (for root for example "/etc # _")

also called "The Swiss Army Knife of Embedded Linux" is a tool which brings into Android basic tools known from unix system, but is much more smaller than standard tools is. But this "packing" brings also limits in possibilities in comparison to standard tools in unix-system (missing special modes of tool, color output and so on). Many application use this. For example busybox grep (filtering of text) is needed for application called Market enabler.

BusyBox commands
list of commands is really wide, so it's not possible explain all, so I pickup only top few. (hint: if you want what some command do, just search on google for "man <command_name>" for example man mv or enter command here
  • cd - cange directory - same like in windows. You can switch directory. example: cd /sdcard
  • ls - list of files in actual directory (have few switches like for example: ls -l /sdcard/*.png (detailed listing)
  • cat - print file into standart output (like more in windows) Example: cat /sdcard/data.txt
  • vi - editing of file. But on limited phone keyboard (no keyboard) it is little harder Read more about vi
  • cp - copy of one or more file. Example: cp /sdcard/bike.jpg /sdcard/media/bike-wallpaper.jpg
  • mv - moving/rename files, Example: mv /sdcard/bike.jpg /sdcard/media/renamed-moved-bike.jpg
  • rm - delete file (rm -R for recursive, or for delete whole folder), Example: rm -R /sdcard/wallpaper-bad/*
  • find - search for files, Example find / -name "best-chopper-ever.avi"
  • mkdir - make directory - creates directory, Example: mkdir mynewdir
  • chmod - changes access of files
  • less - similar like cat, but you can scroll in it and it doesn't produce any output. Example: less /sdcard/funnytext.txt
Please, take note that man pages are documentation of unix tools. For BusyBox's tool help, just enter BusyBox <command_name> -h.

Many time, when is BusyBox installed, are also symbolic links created. It means, that is not necessary do BusyBox <command>, but only <command> will be enough.



Android platform and it's specifics

ADB - Android Debug Bridge is a versatile tool lets you manage the state of an emulator instance or Android-powered device. It is a client-server program that includes three components:

  • A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
  • A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
  • A daemon, which runs as a background process on each emulator or device instance.
Generally it can be compared with standard cmd prompt in windows (you can write commands which will be executed locally, for example in Terminal Emulator) or it can be just like SSH in unix-like system (you connect to terminal through adb client (in Android SDK) and commands will be run remotely.

Android SDK
Android software development kit is complex set of tools for developing app on Android. It includes fully usable emulator of Android OS on your PC, where you can do everything. You can install/delete apps, browse web page in embedded web browser, play games or make your own application in Eclipse (widely used IDE for development). Of course, with emulator you can use also GPS or camera. Emulated android phone is just like "normal" phone.

Android SDK tools
Tools for work with Android adb shell
You have two ways ho to connect into ADB service - locally and remotely.
Locally - for local access you will need some application which can connect to local adb shell.
  • Terminal Emulator (free) - probably most commonly used app from market, which works and looks like standard unix shell.
  • ConnectBot (free) - same as Terminal Emulator, but it can be also used for connecting via SSH or telnet
  • Remotelly- For remote connection you need phone configuration adjustment:

Home desktop -> [menu button] -> Settings -> Applications -> Development -> USB debugging [ON].
Also you need connect your phone via USB (or finds on market some widget/app, witch enable using ADB also via wi-fi)

adb tool from Android SDK
After download Android SDK, extract archive somewhere (in example I extracted it in c:/AndroidSDK). Then follow instruction on developer.android.com for installation of SDK Platform-tools (contains adb). After installation click on start menu and in Run... (in Windows7 in search bar) enter 'cmd' and press Ok or [enter]. Then write in cmd line:
cd c:\AndroidSDK\android-sdk-windows\tools [enter]
now you can enter following command to connect to phone's adb shell if you don't have more connected device (virtual or real-one)
adb shell
If you have more then one, you need explicitly say which one should be used for connection. So list connected devices with
adb devices
which shows you serial number of connected devices. Than use
adb -s <serial-number> shell


Custom recovery

What is custom recovery
Recovery is image (binary data) stored in internal memory. This image contains something like "program" maybe better say "tool", which can boot-up independently on Android system. In other words, when this tool is running (booted up), than Android system is not. This tool is part of phone system, and in PC terminology recovery can by compared to BIOS with some added features. This recovery state can be reached on all phone, but if you don't have custom recovery, it will do offten, but not always so-called HW reset and automatically restart itself into standard boot mode. So what is difference between original recovery and custom recovery? Custom recovery didn't call master reset after start and also didn't restart itself.

Tools which custom recovery provides

Let's go check what custom recovery brings.

ADB as root user

USB-MS Toggle :mounts sdcard as mass storage
It just mounts your phone as USB-mass storage (USB disk) so in PC you will see new disk where you can see folders based on mountes (lower) and were you can upload what you want.

Absolutely GREAT feature. With NAND you can do 1:1 copy (image) of your actual system (phone's memory). It means, that you didn't backup only SMS, contacts or apps, but whole system with all configuration, customization, wallpapers, system's tweaks... just everything - it creates image of whole phone system. This image will be written to your SD card which you are then free to copy around and back up on your computer.

What it means? You find custom ROM which looks awsome so you create NAND backup and install new ROM, but after few hour/days... you know, ROM before was better. So you boot into recovery, use NAND restore of your old ROM backup and .... woala you have your system just like before backup - as if nothing had happened. For about 2 minutes!! It sounds great, isn't? But one, little problem exist. You can not use for restore only some part of backup. You have to restore all, or nothing.

Flash Zip From Sdcard
This tool is designed for install of custom ROM or for tweaks. If you have instruction to install via custom recovery, and file have .zip extension than you should use this menu. Never unzip file, because file contain meta-information about itself with some validate-checks so if you edit it, or unpack and pack back, it shouldn't work. And of course you can't select *.zip file if it doesn't exist because you unpack it, also you have not to rename it to update.zip, you can just select file to update in list of .zip files.


Wipe data/factory reset: wipes data & cache
wipe of users data (contacts, apps, configuration, ...) and cache (caches of applications)

Wipe cache
wipe cache only

Wipe Dalvik cache : Wipes Dalvik cache in all possible locations if moved by apps2sd
wipe of Dalvik cache?

Wipe SD:ext : Wipes Apps2sd ext partition
if you used Partition SDcard option, you can wipe it here

Wipe Battery Stats
If you think, that your battery life is too short, you can try delete battery stats. Than let phone fully charge. (more)

Partition Sdcard:
will create ext2 partition (you will be asked for size of ext2 and cache) Than you can use this space as part of system memory.
  • ext2 - file system for the Linux kernel (no journal, fast but not recovery of I/O error)
  • ext3 - file system for the Linux kernel (journal, slower than ext2 because of journal, but provides recovery on I/O error)
  • ext4 - file system for the Linux kernel (journal, enhanced version of ext3)
Mounting of filesystem parts

Install or not to install?
  • Where can problems arise? 
  • loss of warranty - service have much more advanced software and hardware and they can check what problem caused - make dump of memory and so on. They mostly doesn’t do, but they can. 
  • bricking of phone - if something goes wrong, then phone may not start at all 
  • deletion of all data if installation fails - if old recovery remains, than hw reset will be performed
  • custom recovery doesn't work at all - incompatible devices
Why to try?
  • NAND backup/restore - the most useful tool ever
  • you can install custom ROM
  • high count of successful flashing of custom recovery
  • for now (what I read on forum), when you had said that you brick your phone by standard manufacturer tool, your warranty repair would be probably approved


What is custom ROM?

Custom ROM is every somehow changed manufacturer's ROM or ROM compiled from source code of Android. "Change/s" can starts with adding/removing default application and can extend to kernels, cpu over/under-clocking, enable/disable features (ROOT, HW acceleration, ...), themes (frameworks, color, ...), keyboards and many other features.

Custom ROM is mostly distributed like signed ZIP package with included installation script for custom recovery. This ZIP is flashed via custom recovery tool.

Is it save to install custom ROM?

Yes, it is. May be I can say, that installation of custom ROM is almost mandatory, because it cost you only few minute if you will not be satisfied - you can just restore your old ROM from NAND backup, if you will be satisfied, you can keep it. And yes, you can also use backup tools like for example Astro for backup of your apps or Titanium Backup backup everything (SMS, call list, preferences, APNs, ...) and restore this in your new ROM (NOTE: In this case it's strongly recommended that both ROM should have same or very similar source/base ROM).

So, it is really simple:

  1. Do NAND backup
  2. Try new ROM
  3. Keep new, or restore old one.

What I need for install?

  1. Rooted phone
  2. Installed custom recovery
  3. Signed .ZIP file of ROM compatible with recovery
  4. RECOMMENDED: NAND backup of your actual ROM

What does custom ROM bring

Custom ROM brings almost every feature you can image.


  1. optimization for maximal power (games), long battery life, calling, texting, playing videos,...
  2. awsome look - changed icons, colors, animations, wallpapers, menu, ....
  3. simple work - feature that will short some work (add restart button, reorganized menu, shorts, gestures, ...)
  4. allow tweaking - overclok/underclok your device, ROOT, ....
  5. and many other
It's really not possible describe here every possibility what you can do/get with custom ROM.

what is ...

deodexed - needed for using themes. If you want replace/change some file in system (change theme) you need deodex file which you want change. In most cases it's going on services.jar which contains definition of colour for clock for example.

APKs zipaligned - optimization of APK archive, so it takes less memory and is much faster.

png-optimized - png files takes less memory, are loads faster

JIT - just-in-time compilation also known as dynamic translation, is a method to improve the runtime performance of computer programs, but it takes some time to convert into it on start.

HW:acceleration - using of HW acceleration for rendering GUI. Little increase battery consumption.

VM.Heap Size - maximum memory an application can consume

stagefright - In Android 2.2 new media framework that supports local file playback and HTTP progressive streaming

Apps2SD - (mostly DarkTremor's a2sd) If you create ext partition on your SD card, you can mount it like internal memory (you will have more space on phone memory) and move app on SD.
Dalvik2SD - move of Dalvik into SDcard (saves space)
custom kernel - compiled standard unix kernel (can bring support for features like support ext4 for example)

su (Unix); wikipedia.org
Superuser; wikipedia.org
Bourne shell (sh); wikipedia.org
Bourne-Again shell (bash); wikipedia.org
BusyBox; benno.id.au; BusyBox.net
Kernel; wikipedia.org

How to increase battery life; androidforums.com
Comparison of file systems; wikipedia.org
ZeroXtreme's filesystem answer (thanks); forum.xda-developers.com

ADB; android-dls.com; developer.android.com
Android SDK; wiki.androidforum.cz [CZ]
Basic adb/shell commands for noobs; forum.xda-developers.com
15 Useful Android Terminal (ADB Shell) Commands; gadgetsdna.com

P500 custom ROM list; forum.xda-developers.com
What's Deodex and Odex?; forum.xda-developers.com
What Is Zipalign In Android www.addictivetips.com
PNG compress; http://www.gotow.net/creative/wordpress/?p=79
Just-in-time compilation; wikipedia.org
VM Heap size; forum.cyanogenmod.com
Stagefright; developer.android.com

Žádné komentáře: