Sunday, 24 November 2013

Android Architecture

Android Architecture.

Android Architecture Diagram.



Android Architecture contains four layers.
  1. Linux Kernel.
  2. Libraries & Android Runtime.
  3. Application Framework.
  4. Application.

1. Linux Kernel.

The basic layer is the Linux kernel. The whole Android OS is built on top of the Linux Kernel with some further architectural changes made by Google. It is this Linux that interacts with the hardware and contains all the essential hardware drivers. Drivers are programs that control and communicate with the hardware. For example, consider the Bluetooth function. All devices has a Bluetooth hardware in it. Therefore the kernel must include a Bluetooth driver to communicate with the Bluetooth hardware. The Linux kernel also acts as an abstraction layer between the hardware and other software layers. Android uses the Linux for all its core functionality such as Memory management, process management, networking, security settings etc. As the Android is built on a most popular and proven foundation, it made the porting of Android to variety of hardware, a relatively painless task.


2. Libraries & Android Runtime.

  1. Libraries.
    Native Libraries mostly came from other open source project. Some of important Native Libraries are,

    WebKit : Library for Fast HTML Rendering.
    OpenGL : Library for Graphics.
    Media Codecs : Library offers support for major audio/video codecs.
    SQLite : Library for Database.

  2. Android Runtime.
    Android Runtime consists of Dalvik Virtual Machine and Core Java Libraries.

    1. Dalvik Virtual Machine.
      Dalvik VM is android implementation of Java VM. Dalvik is named after fisherman village in Iceland. It is developed by Dan Bornstein of Google. Unlike the JVM, the Dalvik Virtual Machine doesn’t run .class files, instead it runs .dex files. .dex files are built from .class file at the time of compilation and provides higher efficiency in low resource environments.

      Why Android replaces Java VM with Dalvik VM.
      Business Reason : Because Java is owned by Oracle so it cost Money.
      Technical Reason : Davik is optimized for mobile devices to reduce Battery and Memory Consumption and to increase CPU Capabilities.

      Key Dalvik Differences.
      • Register-based versus stack-based VM.
      • Dalvik runs .dex files.
      • More efficient and compact implementation.
      • Different set of Java libraries than JDK.

    2. Core Java Libraries.
      Android contains all Java SE libraries except AWT and Swing.


      In Standard Java, we compile our Java Code using JavaC Compiler and we get Class Files and we run our Class files on top of JVM.
      In Android, we compile our Java Code using JavaC Compiler and we get Class Files and we recompile Class Files using DEX Compiler and we get Dalvik Executable and we run Dalvik Executable on top of Dalvik VM.
      During APP Development we don't care about it because system takes care of all these things by itself.


3. Application Framework.

Application Framework is basically exposing capabilities of the Platform to Apps.
As a App Developer, we can use Application Framework to interact with system to get information or to save information and we can do much more things.

Important Blocks of Application Framework are.
Activity Manager : Manages the activity life cycle of application.
Content Providers : Manages the data sharing between application.
Telephony Manager : Manages all Voice. We use Telephony Manager if we want to access voice calls in our application.
Location Manager : Location Management, using GPS and Cell Tower.


4. Application.

Application are the top layer in the Android Architecture and this is where our applications are going to fit. Several standard application comes pre - installed with device, such as

  • SMS Client App.
  • Dialer
  • Web Browser.
  • Contact App.

Application format for Android is .apk. Dalvik Executable + Resources = APK


Dalvik Exe - Java Code that we write is complied into Dalvik Executable.
Resources : It is not Code, it is Image, Video, Xml, Strings etc.
Native Libs : Apps may or may not contains Native Libs. For example Angry Birds contains Physics Engine written in C.


References

http://en.wikipedia.org/wiki/Android_version_history
http://en.wikipedia.org/wiki/Android_version_history
http://developer.android.com/about/dashboards/index.html

No comments:

Post a Comment