Introduction
Android is a Linux-based open source software stack that comes along with operating system , middleware, native mobile applications, along with set of API (Application programming interface)libraries for building third party applications. It was designed primarily for touchscreen mobile devices such as smartphones, tablets and now its focus has spread wider across other embedded systems. Initially developed by Android Inc.,(founded in 2003 and is based in Palo Alto, California) which operated as subsidiary of Google and later purchased by Google in 2005.
Android was publicily announced in 2007 and first phone was sold on October 2008. Thats a short introduction about Android and its history.
Background
Kernel in android OS is Linux, it makes use of Linux kernel 2.6 and 3.x(Android 4.0 onwards), so Android is a linux based operating system
Note that :Although the kernel in the android OS is Linux,Android is not a Linux operating system as it does not include the full set of Linux utilities
Why the Linux Kernel
- It's opensource
- Support shared libraries
- proven driver model
- permission based -security model
Anatomy Of The Android Frame Work
Android OS consists of four main layers kernel, libraries, applications framework and applications as illustrated in the diagram .Each layer playing important function as am going to discuss to you
The kernel
The whole Android OS is built on top of the Linux 2.6 Kernel with some further architectural changes made by Google to facilitate mobile limitation which include memory management and power management. It is this Linux that interacts with the hardware and contains all the essential hardware drivers. Linux was chosen since it is already opensource ,has a proven track record in desktop systems and in many cases doesn’t require drivers to be rewritten. Linux provides such things as virtual memory, networking, drivers, power management,inter process commmunication (IPC) and debuggers
Application and services run on seperate processes but have to share the same data and communicate therefore this an cause a signficant security loopholes and processes ending in a deadlock as they do the IPC.
The solution to this was to create;
- A driver to facilitate IPC called the Binder(IPC ) driver.
- Enable shared Memory
- Pre-process pool for processing requests
- Synchronous calls between process
The other issue is with Power management .Since Mobile phones use rechargeable batteries that a limited power capacity.Another customised driver was incorparted into the kernel called the Power Management driver(PM) ,this was built on top of the standard Linux Power Management Driver with;
- A more regulative power management policy
- Components making calls to keep power on through "wake locks"
- Supporting more wake locks
http://git.android.comto get the full sourcecode of the Android Kernel
Libraries
THe Android framework is shipped with 9 native libraries but 3rd Party libraries can also be added to this layer .
This native libraries can be classified as folows:
- Native Servers
- Functional Libraries
- Bionic Libc and
- Hardware Abstraction Libraries
Native Servers
This include ;
Surface Manager which is responsible for rendering the 3D and 2D grahics
OpenGLIES this is also responsible the 2D and 3D rendering with diffferent hardware accelerometers
Audio ManagerManages all audio output devices
Functional Libraries
This include;
SQLite alight weight relational database.Acts as a backend for most platform data storage
WebKit is based on open source WebKit browser:http://webkit.org,Full CSS, Javascript, DOM, AJAX support enabling programmers to build brower based application
Media FrameworkSupports standard video, audio, still-frame formats
Bionic Libc
This library was specifically built for to cater for the limitation with mobile devices like memory management,limited CPU power , therefore this library enables small size and fast code paths allowing very fast and small custom pthread implementation
The HardWare Abstraction layer
This layer is responsible with separating the Android Logic from the Hardware interface.This layer mostly contains user C/C++ librabries that's why it's also posssible to develop android natively with a number of languages which include C,C++ etc.
It also provides an interface that Android requires hardware drivers to implement
Importance of this layer
- Not all components have standardized kernel driver interfaces therefore this layer provides this drivers for the unkown
- Android has specific requirements for hardware drivers
Android Runtime
This includes two layers that include the ;
- Core Java Libraries This are completely written in Java withCore APIs for Java language provide a powerful, yet
simple and familiar development platform
• Data structures
• Utilities
• File access
• Network Access
• Graphics - Dalvik Virtual Machine Androidʼs custom clean-room implementation virtualmachine that caters for mobile limitations
• Provides application portability and runtime consistency
• Runs optimized file format (.dex) and Dalvik bytecode
• Java .class / .jar files converted to .dex at build time
• Supports multiple virtual machine processes per device
• Highly CPU-optimized bytecode interpreter
• Uses runtime memory very efficiently
Application Framework
This contains core system services that will be used by Applications created by you or any programmer,they work behind the scenes i.e applications do not access them directly and they divide into two categories that include;
- Core Platform Services • Activity Manager
• Package Manager
• Window Manager
• Resource Manager
• Content Providers
• View System - Hardware Services • Telephony Service
• Location Service
• Bluetooth Service
• WiFi Service
• USB Service
• Sensor Service
For example to use the Location Service to get GPS position of a user.You would have to request for the location service
LocationManager lm = (LocationManager)
Context.getSystemService(Context.LOCATION_SERVICE);
Run time cycle
Just like most Linux-based systems at startup, thebootloader loads the Linux kernel and starts the init process.
Init starts Linux daemons, including:
- USB Daemon (usbd) to manage USB connections
- Android Debug Bridge (adbd) to manage ADB connections
- Debugger Daemon (debuggerd) to manage debug processesrequests (dump memory, etc.)
- Radio Interface Layer Daemon (rild) to manage communicationwith the radio
Init process starts the zygote process:
- Initializes a Dalvik VM instance
- Loads classes and listens on socket for requests to spawn VMs
- Forks on request to create VM instances for managed processes
Note: the Zygote and Dalvik VM are virtual processs
The Dalvik VM then intiaties the the native system servers that include the Surface
Flinger and Andio Flinger.After the server has loaded all the system services then the system is ready
Note;Each subsequent application is launched in itʼs own process