Black God

Android – Under the hood

android-sourceAndroid is the Google’s open source Operating System designed for mobile devices. Apart from Google, most of the top players of mobile industries are behind Google developing this linux kernel based OS.

What the project says about itself?

Android is the first free, open source, and fully customizable mobile platform. Android offers a full stack: an operating system, middleware, and key mobile applications. It also contains a rich set of APIs that allows third-party developers to develop great applications.

This project comprises of three areas for various levels of user and contributors.

1. Operating System Source Code maintained at http://source.android.com/. If you really want to contribute to kernel level coding of this exciting OS, go to this site and contribute or learn as you wish or capable. But it is sure that your hands will become dirty to maximum extent in this heavily customized linux kernel.

The Project layout as per the site is

The Android platform consists of several projects already in progress. These projects can be divided into three categories:
  • Core projects:  These projects make up the foundation of the Android platform.
  • External projects:  The Android Open Source Project makes use of many other open source projects.
  • Packages:  These projects are standard Android applications and services.

2. Software Development Kit (SDK) for Android is maintained at http://developer.android.com/. This aims at Application developers who can make wonderful innovative application on top of powerful and simple framework of Android. The SDK will take care of all under the hood technologies like getting GPS information, data from camera, input methods, hardware dependent stuffs, etc. Application developer needs to be innovative, rest the SDK will do. But one drawback for non-Java people is JAVA is the only supported application development environment. Though a powerful Phone Emulator is available with SDK, Google is selling one phone per developer to test the application on real hardware. This Phone is completely unlocked in both SIM and Boot loader wise.

3. Android market is the one where end user can download both free and paid applications. These applications are expected to be compatible with any mobile phone based on Android OS.

In the next part of this series, first let us see the Architecture of Android in simple way. Then let us jump into the all low level dirty stuff.

The scope of this article is restricted as below:

I am not going to pin point all but some of the important features to remember.

When a figure is more clear, I don’t like to explain it further.

Where ever possible I will try to give some authentic documentation link.

It is assumed that reader has some basic OS knowledge.

Architecture of Android

Android provides everything in a software stack right from dirty kernel to creamy applications. See the figure below which is more self explanatory.  There five major layers in the architecture.

Android Architecture - Click image to enlarge

Android Architecture - Click image to enlarge

The bottom most Linux kernel layer is the one which does all magic of interacting with the hardware which includes full featured kernel (2.6.25 kernel as of now) and drivers for hardware. Power management is more specific to hardware, so it is also handled by the linux kernel. This kernel is optimized for mobile platform and processor specific.

The next layer is Android Runtime, which is unique to this platform. This layer has JAVA core libraries on top of Dalvik Virtual Machine. Each application in android will be running a process which in turn has its own instance of this virtual machine. This help clear isolation of data of one process with another (cool, but there is a mechanism to share!).

Flow of Java source to running instance of an application

Flow of Java source to running instance of an application

Next layer is Libraries. This layer comprises of C/C++ libraries which interacts with services offered by kernel. Functionality of Android of heavily depends on this layer. In short we can summarize like this.

1. Surface Manager – interfacing display sub system

2. Media frame work – provides libraries to encode and decode autio/video/image files

3. SQLite – Light weigth database which is a RDBMS also.

4. OpenGL – 3D graphics engine either uses 3D acceleration if available or 3D software acceleration

5. SGL – 2D graphics engine

6. WebKit – This is the browser engine. Apple’s Safari, KDE’s konquerer and Google’s Chrome are also based on this engine only. All our browser and web applications are powered by this engine in Android.

7. Free Type – a font rendering engine

8. SSL – Secure Socket Layer provides secured connection service to network applications

9. libc – our own standard good old Standard C Libraries

All these are already established open source projects. Android has a version of these libraries optimized for mobile platform.

Why should kernel, libraries and everything should be optimized for mobile platform? What way PC/Server based code is different from mobile/embedded platform?

1. Mobile platform is powered by battery which has its own charge/discharge cycle. So your device should consume as less power as possible so that standby and usage time will be more. This is not the case of PC/Server powered by Mains supply.

2. The processor is not as powerful as desktop/server systems (more powerful processor takes consumes more power), so you can expect limited multi-core, multi-thread, cache levels support to run your applications.

3. Input devices are numerous. We have to support standard mobile numeric keypad, QWERTY keyboard, Stylus input, Touch input, Multi-touch input (patented by Apple, Inc.), Voice input, Bluetooth device based special input devices, some special sensors, etc.

4. Output display area is very limited (though nowadays it is exciting and growing fast). Designing application’s GUI compatible with different hardware (mobile) is very difficult.

Next layer is Application Framework. This provides the API for the application developers. It makes the life of developers simple, they can concentrate on innovative application development than worrying about behind the hood dirty stuff.  This layer provides various controls used in GUI development, resource management like image and strings, data sharing between applications, common user notification management, etc.

The top most layer is the cute and sweet applications which end user uses to achieve their tasks. it includes phone functionalities, browser, email client, maps and countless applications.

In the next section, let us go further into the layers.

3 comments for “Android – Under the hood

  1. Severina
    August 28, 2009 at 1:58 pm

    I understand now. Thanks for the post!

  2. June 7, 2009 at 2:43 pm

    thnx

  3. May 20, 2009 at 12:36 pm

    I heard something about this, but for me it’s difficult so I do not quite understand all this!

Leave a Reply

Your email address will not be published. Required fields are marked *