Android Architecture¶
Android Architecture¶
OS - manages resources of system and provides way for applications to talk to hardware
History
- Open Handset Alliance (OHA) formed to defined mobile standards and came up with Android (2008)
Tech stack¶
[Diagram — add to assets/ if available]
[Diagram — add to assets/ if available]
Linux Kernel Layer¶
- Went with Linux mainly because it was a portable platform
- Kernel - abstraction layer between hardware and software
- Eg: camera click(hardware instr) -> take picture and store it in gallery (software)
- Instr goes to corresponding hardware driver in the linux kernel
- The camera driver then sends signals to the hardware
- Kernel responsible for managing core functionality if Andoird such as process management, memory management, security and networking
Hardware Abstraction Layer¶
- Device h/w capabilities are exposed to high-level Java framework through the HAL
- Consists of several library modules that implement interfaces for a specific type of hardware component
- Provides standard interface for h/w vendors to implement device-specific functionality without modifying higher-level Andoird code
Android Native Libraries¶
- Written in C/C++ to help device handle different kinds of data
- Eg: SQLite used for storing and retrieving the data from a database
- Others include Media Framework, WebKit , Surface Manager and SSL
- In the same layer, we have Android Runtime and core libraries
Dalvik Virtual Machine¶
There used to be an intermediate compiler called Dex compiler to convert Java bytecode to Dalvik bytecode (.class converted to .dex files using dx tool)
Dalvik Virtual Machine runs the Dalvik bytecode
Why?
- Android used to be very resource constrained,(low memor and low-processing)
- JVM byte code contains one or more .class files depeidning on number of Java files present in the application
- Dalvik bytecode comprises a single .dex file.
- Each Android app runs its own instance of DVM. Thiis a critical aspect of Android security
Andoird Runtime (ART)¶
Early version(Dalvik) → Just-In-Time compilation - compiles byte code to Dalvik byte code everytime an app is launched
ART → Ahead of Time compilation - compiles entire applications into native machine code upong installation
Why?
- Increases installation time
- but reduced efficiency and power consumption during use
ART uses a utility called dex2oat t
- accepts DEX files as input
- generated compiled app executable for target device (.odex - optimised dex)
Java API Framework Layer¶
Responsible for handling basic functionalities of phone
eg, resource management, handling calls and so on
This is the block with which the applications installed on the device directly talk to
Has a bunch of different managers
- Activity Manager: Controls all aspects of app lifecycle and activity stack
- Telephony Manager: Manages all voice calls
- Content provider: Manages publishing and sharing of data between different applications
- Resource Manager: Helps manage various resources used in applications - strings, color setting, UI etc
- Notification Manager - allows app to display alerts and notifications to user
- Pacakge Manager - applications are able to find out info about other apps installed on the device
- Location Manager - location based services and updates
System Apps Layer¶
topmost layer where user can interact directly with the device. There are two kinds of applications:
- Pre-installed(system apps): eg: web browser, contacts, dialer that comes along with the device
- User-installed apps: Can be downloaded from different places like Google Play and so on