Friday 30 September 2011

A Journey to the Centre of Android


Android is an open source OS for mobile platforms based on Linux kernel developed by Google in alliance with the Open Handset Alliance. Android is perhaps the hottest topics around. Here I will talk about the architecture of Android. We can dissect the Android architecture in five different sections.

android-architecture-485bAndroid Architecture

1. The Linux kernel: The Android relies on Linux 2.6 kernel for security, process management,network stack, memory management and driver model. It also acts as a layer of abstraction between the hardware and the rest of the software stack. The major Android kernel features are the following: Binder: The binder is derived from OpenBinder in Linux. OpenBinder is system-level component architecture, designed to provide a richer high-level abstraction on top of traditional modern operating system services.

Power: It manages the power and is implemented through wake locks. Every time the Android boots it searches for the battery and if not found throws an error saying insufficient power and then shuts down. This is encountered when you try to port Android on any board say a Beagle board. A particular line has to be commented out in power management source code to avoid this.

Ashmem: This is the anonymous shared memory subsystem of Android.

Low memory killer: This used to kill applications when the Android is running low on memory. Suppose you get an incoming call but your phone is low on memory. The low memory killer then kills the application with the least priority and creates space in the memory so that you can receive your call.

Logger: Logs all information (including boot time information) which can be retrieved later by user space with logcat command.

ADB: Android Debug Bridge is a debugging protocol over USB.

2. Native libraries: Android includes a set of C/C++ libraries used by various components  of  the Android system. It includes system C libraries, media libraries, surface manager (manages access to display sub-sytem), SQLite (a light-weight relational database) etc.

3. Android runtime: Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. As soon as you enter the init part of the kernel, you enter the Android. In this you will find “Zygote” which is a nascent process. It provides access to the Dalvik Virtual Machine. For every application that runs on Android, a separate DVM instance is spawned by the Zygote. That means each application runs on separate instances of the DVM. This optimizes the memory footprint. The DVM is similar to JVM or Java Virtual Machine, but there are two basic differences. DVM is register based  whereas  JVM is  stack based.  And secondly, all applications run on the same instance of JVM but a separate instance is spawned for each application in case of DVM.

4. Application framework: Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify  the  reuse  of  components;  any application can publish its capabilities and any other application  may  then  make  use  of  those capabilities (subject to security constraints enforced by the framework). This same  mechanism  allows components to be replaced by the user. They include Activity manager, Window Manager, Package manager, Resource manager etc.

5. Android applications: Android will ship with a set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.

No comments:

Post a Comment