Android Architecture stack

Gaurav Bansal
4 min readMay 28, 2018

--

In this article we will discuss about the android architecture stack.

Android is a mobile operating system developed by Google, based on a modified version of the Linux kernel.Android is built in linux kernel but it is not linux.It doesn’t have native windowing system,it doesn’t have glibc support and also doesn’t include full set of standard linux utilities.

Android architecture stack diagram

Linux Kernel-

Why Linux kernel in android-

  • Great memory and process management.
  • Permission based security model.
  • Power driver model- It provides grate hardware abstraction layer
  • Support for shared libraries
  • It’s already open source.

Kernel enhancement-
A lot of enhancements are made on kernel.

  • Alarm driver is added that provide timers,timers can wake up device from sleep on time basis.
  • Ashmem(Android shared memory) driver that allows application to share memory and manages this at kernel level.
  • Binder-Which is an open binder based IPC driver that facilitate inter process communication.It is high performance through shared memory.It supports synchronous calls between processes.
  • Low Memory killer
  • Kernel debugger
  • Power management driver- As android mobile devices run on battery so there is always limitation. Android have implemented aggressive power management policy on top of original linux power management. Wakelocks like Partial and full wake locks are added .
  • Logger

Hardware abstraction Layer-

Linux kernel provide abstraction layer for hardware but all the hardware component doesn’t have standardised interface in standard linux kernel,So android have implemented a HAL above kernel in android architecture.It provide user space abstraction layer between hardware and application framework.It defines the interface that android requires hardware driver to implement.It have components like LED driver,Bluetooth driver and many more hardware driver.

Native libraries-

  • Bionic libraries- Custom libc implementation optimized for embedded usage.Custom libc implemented because
    i)Standard C library is GPL(general public license) and android want to get rid of license issues.
    ii)Mobile device have limited memory resources so it has to be very small.It’s size is 200Kb(Half of Standard libc).
    iii)It should be very fast on less powered Mobile CPU .
    It is licensed under BSD.
  • Function libraries-It have following libraries.
    i)WebKit-It’s based on open source WebKit browser.It renders pages in full desktop view.It have fill CSS, Javascript, DOM,AJAX support.
    ii)Media Framework- It’s based on PacketVideo OpenCORE platform,It support standard video, audio format.It also support hardware/software codec plugins.
    iii)SQLite-Light weight transactional data storage.This provides the backend storage for persistent data on the android platform.
  • Native servers- These are the processes running to control the i/o on devices.
    i)Surface Flinger-It provides system wide surface composer, handling all surface rendering to frame buffer device.It takes surface drawn by different applications which running on different processes and compose them all onto the single frame buffer to output to device display.Surface passed as buffers via binder IPC calls.

Android Runtime-

It is on top of native libraries layer.It provides virtual machine to run app and core libraries(Exposed through java programming).
It is android custom clean-room implementation virtual machine.It provide application portability and runtime consistency.It runs optimized file format(.dex) and Dalvik bytecode. Java code files are converted to .dex files at build time.It is designed specifically for embedded environment. It supports multiple VM processes per device.It uses runtime memory very efficiently.It have highly CPU-optimized bytecode interpreter.

For devices running Android version 5.0 (API level 21) or higher, each app runs in its own process and with its own instance of the Android Runtime (ART). ART is written to run multiple virtual machines on low-memory devices by executing DEX files, a bytecode format designed specially for Android that’s optimized for minimal memory footprint. Build toolchains, such as Jack, compile Java sources into DEX bytecode, which can run on the Android platform.

Some of the major features of ART include the following:

  • Ahead-of-time (AOT) and just-in-time (JIT) compilation
  • Optimized garbage collection (GC)
  • Better debugging support, including a dedicated sampling profiler, detailed diagnostic exceptions and crash reporting, and the ability to set watchpoints to monitor specific fields

Prior to Android version 5.0 (API level 21), Dalvik was the Android runtime. If your app runs well on ART, then it should work on Dalvik as well, but the reverse may not be true.

Core libraries-Android also includes a set of core runtime libraries that provide most of the functionality of the Java programming language, including some Java 8 language features, that the Java API framework uses.

Application framework-

It is on top of android runtime.It is all written in java programming language and it contains core platform services like Activity manager, Package manager, View manager, Window manager that will be used by apps.It also provides java language bindings for the native libraries.
Core platform services are essential to android platform that manage application lifecycle, loading resources, managing packages.

Core platform services-

  • Activity manager-It manage application lifecycle for all the activities.It maintains a back stack to navigate in application.
  • Package manager- This is used by activity manager to load information about all the apk files on android device.Package manager exposes apps and their capabilities to system.
  • Window manager- This sits on top of surface flinger handles all the window drawn by various applications.
  • Resource manager- It handles all non code resources in an application or service.It include externalise strings, image etc.
  • Content providers-It allow to share data between applications.
  • View System-It provides all the standard widgets like buttons, map view, date picker view.It also manages view hierarchy.
  • Lower level Hardware Services- provide access to lower level hardware api via services like Location services, Telephony services,Bluetooth services,Wifi services,Sensor services.

It’s all about the android platform architecture, for more details about android run time and compiler check following posts.

--

--