SlideShare a Scribd company logo
Android Architecture
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Android System Architecture
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Linux Kernel
● Android is built on the Linux kernel, but
  Android is not Linux
● No native windowing system
● Does not include the full set of standard
  Linux utilities
● Patch of “kernel enhancements” to support
  Android
Why Linux Kernel?
●   Great memory and process management
●   Permissions-based security model
●   Proven driver model
●   Support for shared libraries
●   It's already open source!
Kernel Enhancements
• Binder
• Power Management
Binder: Problem
● Applications and Services may run in separate
  processes but must communicate and share
  data
● IPC can introduce significant processing
  overhead and security holes
Binder: Solution
● Driver to facilitate inter-process communication
  (IPC)
● High performance through shared memory
● Per-process thread pool for processing
  requests
● Reference counting, and mapping of object
  references across processes
● Synchronous calls between processes
Binder in Action
Binder in Action
Binder in Action
Binder in Action
Binder in Action
Binder in Action
Binder in Action
Binder



Android Interface Definition Language (AIDL)

http://developer.android.com/guide/components/aidl.html
PM Problem
● Mobile devices run on battery power
● Batteries have limited capacity
PM Solution
● Built on top of standard Linux Power
  Management (PM)
● More aggressive power management policy
● Components make requests to keep the
  power on through “wake locks”
● Supports different types of wake locks
Android PM in Action
Android PM in Action
Android PM in Action
Android PM in Action
Android PM in Action
Android PM in Action
Android PM
● Use wake locks carefully!
● sysfs entries for wakelocks in android
  "/sys/power/wake_lock",
  "/sys/power/wake_unlock",
  "/sys/power/state"
Kernel
Download and Build android kernel from:

http://source.android.com/source/building-
kernels.html
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Native Libraries
Native Libraries
●   Bionic Libc
●   Function Libraries
●   Native Servers
●   Hardware Abstraction Libraries
Native Libraries
●   Bionic Libc
●   Function Libraries
●   Native Servers
●   Hardware Abstraction Libraries
What is Bionic?
● What is bionic?
  Custom libc implementation, optimized for
  embedded use.
What is Bionic?
Why build a custom libc library?
● License: we want to keep GPL out of user-
  space
● Size: will load in each process, so it needs to
  be small
● Fast: limited CPU power means we need to
  be fast
Bionic libc
● BSD License
● Small size and fast code paths
● Very fast and small custom pthread
  implementation
Bionic libc
● Built-in support for important Android-
  specific services
  a. system properties
     getprop(“my.system.property”, buff, default);
  b. log capabilities
     LOGI(“Logging a message with priority ‘Info’”);
Native Libraries
●   Bionic Libc
●   Function Libraries
●   Native Servers
●   Hardware Abstraction Libraries
WebKit
● Based on open source WebKit browser: http:
  //webkit.org
● Renders pages in full (desktop) view
● Full CSS, Javascript, DOM, AJAX support
● Support for single-column and adaptive view
  rendering
Media Framework
● Based on PacketVideo OpenCORE platform
● Supports standard video, audio, still-frame
  formats
● Support for hardware / software codec plug-
  ins
SQLite
● Light-weight transactional data store
● Back end for most platform data storage
Native Libraries
●   Bionic Libc
●   Function Libraries
●   Native Servers
●   Hardware Abstraction Libraries
Surface Flinger




● Provides system-wide surface “composer”, handling all
    surface rendering to frame buffer device
●   Can combine 2D and 3D surfaces and surfaces from
    multiple applications
Surface Manager
● Surfaces passed as buffers via Binder IPC
  calls
● Can use OpenGL ES and 2D hardware
  accelerator for its compositions
● Double-buffering using page-flip
Audio Flinger




● Manages all audio output devices
● Processes multiple audio streams into PCM audio out
    paths
●   Handles audio routing to various outputs
Native Libraries
●   Bionic Libc
●   Function Libraries
●   Native Servers
●   Hardware Abstraction Libraries
Hardware Abstraction Layer
Hardware Abstraction Libraries
● Why do we need a user-space HAL?
  ○ Not all components have standardized kernel driver
    interfaces
  ○ Kernel drivers are GPL which exposes any
    proprietary IP
  ○ Android has specific requirements for hardware
    drivers
Hardware Abstraction Libraries
● Libraries are loaded dynamically at runtime
  as needed
  QualcommCameraHardware.cpp
  ...
  libqcamera = dlopen(“/system/lib/liboemcamera.so”, TLD_NOW);
  ...
  *(void **)&LINK_camera_init = ::dlsym(libqcamera, "camera_init");
  ...
  LINK_camera_init();
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Android Runtime
What is the Dalvik VM?
● Android's custom clean-room
  implementation virtual machine
● run on a slow CPU
● with relatively little RAM
● on an OS without swap space
● while powered by a battery
Dalvik Virtual Machine
● Provides application portability and runtime
  consistency
● Runs optimized file format (.dex) and Dalvik
  bytecode
● Java .class / .jar files converted to .dex at
  build time
Core Libraries
● Core APIs for Java language provide a
  powerful, yet simple and familiar development
  platform
  ○   Data structures
  ○   Utilities
  ○   File access
  ○   Network Access
  ○   Graphics
  ○   …
.dex file
.jar Vs .dex
.class files
.dex file
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Application Framework
Core Platform Services
● Services that are essential to the Android
  platform
● Behind the scenes - applications typically
  don't access them directly
Core Platform Services
● Activity Manager
Core Platform Services
● Activity Manager
● Package Manager
Core Platform Services
● Activity Manager
● Package Manager
● Window Manager
Core Platform Services
●   Activity Manager
●   Package Manager
●   Window Manager
●   Resource Manager
Core Platform Services
●   Activity Manager
●   Package Manager
●   Window Manager
●   Resource Manager
●   Content Providers
Core Platform Services
●   Activity Manager
●   Package Manager
●   Window Manager
●   Resource Manager
●   Content Providers
●   View System
Hardware Services
● Provide access to lower-level hardware APIs
● Typically accessed through local Manager
  object

  LocationManager lm = (LocationManager) Context.getSystemService
  (Context.LOCATION_SERVICE);
Hardware Services
● Telephony Service
Hardware Services
● Telephony Service
● Location Service
Hardware Services
● Telephony Service
● Location Service
● Bluetooth Service
Hardware Services
●   Telephony Service
●   Location Service
●   Bluetooth Service
●   WiFi Service
Hardware Services
●   Telephony Service
●   Location Service
●   Bluetooth Service
●   WiFi Service
●   USB Service
Hardware Services
●   Telephony Service
●   Location Service
●   Bluetooth Service
●   WiFi Service
●   USB Service
●   Sensor Service
Android System
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Inside The System
● Connectivity
  ○ Bluetooth
  ○ WiFi
● Power Management
● Display & Multimedia
  ○ Display Subsystem
  ○ Audio Subsystem
  ○ Camera/Video Subsystem
● Telephony
Connectivity
● Bluetooth
● Wi-Fi
Bluetooth




Note: Android 4.2 introduces a new Bluetooth stack optimized for use with
Android devices. The new Bluetooth stack developed in collaboration between
Google and Broadcom replaces the stack based on BlueZ and provides
improved compatibility and reliability.
Wi-Fi
● Android uses wpa_supplicant as the platform
  interface to the Wi-Fi device.
● Your Wi-Fi driver must be compatible with
  the standard wpa_supplicant
Wi-Fi
Inside The System
● Connectivity
  ○ Bluetooth
  ○ WiFi
● Power Management
● Display & Multimedia
  ○ Display Subsystem
  ○ Audio Subsystem
  ○ Camera/Video Subsystem
● Telephony
Power Management
Inside The System
● Connectivity
  ○ Bluetooth
  ○ WiFi
● Power Management
● Display & Multimedia
  ○ Display Subsystem
  ○ Audio Subsystem
  ○ Camera/Video Subsystem
● Telephony
Display & Multimedia
● Display Subsystem
● Audio Subsystem
● Camera/Video Subsystem
Display Subsystem
Audio Subsystem
Camera/Video Subsystem
Android Multimedia Framework
Inside The System
● Connectivity
  ○ Bluetooth
  ○ WiFi
● Power Management
● Display & Multimedia
  ○ Display Subsystem
  ○ Audio Subsystem
  ○ Camera/Video Subsystem
● Telephony
Telephony
● Radio Interface Layer

  Android's Radio Interface Layer (RIL) provides an
  abstraction layer between Android telephony services
  (android.telephony) and radio hardware.
Radio Interface Layer
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Runtime Walkthrough
It all starts with init…

Similar to most Linux-based systems at startup,
the bootloader loads the Linux kernel and starts
the init process.
Runtime Walkthrough
● 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 processes requests
       (dump memory, etc.)
   ○   Radio Interface Layer Daemon (rild) to manage communication with
       the radio
Runtime Walkthrough
● Init process starts the zygote process:
   ○ A nascent process which 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
   ○ Copy-on-write to maximize re-use and minimize footprint
Runtime Walkthrough
● Init starts runtime process:
   ○ Initializes Service Manager – the context manager for Binder that
        handles service registration and lookup
    ○   Registers Service Manager as default context manager for Binder
        services
Runtime Walkthrough
● Runtime process sends request for Zygote to start
  System Service
Runtime Walkthrough
● Runtime process sends request for Zygote to start
  System Server
  ○ Zygote forks a new VM instance for the System Service process and
       starts the service
Runtime Walkthrough
● System Service starts the native system servers,
  including:
   ○   Surface Flinger
   ○   Audio Flinger
Runtime Walkthrough
● Native system servers register with Service Manager as
  IPC service targets:
Runtime Walkthrough
● System Service starts the Android managed services:
Runtime Walkthrough
● Android managed Services register with Service
  Manager:
Runtime Walkthrough
Runtime Walkthrough
After system server loads all services, the system is
ready…
Runtime Walkthrough
After system server loads all services, the system is
ready…
Runtime Walkthrough
After system server loads all services, the system is
ready…
Runtime Walkthrough
Each subsequent application is launched in it's own
process
Agenda
●   Linux Kernel
●   Native Libraries
●   Android Runtime
●   Application Framework
●   Inside The System
    Connectivity(Bluetooth,WiFi...)
    Power Management
    Display & Multimedia (Surfaceflinger, Audioflinger,Camera/Video)
    Telephony (Radio Interface Layer)
● Android Boot sequence
● Layer Interaction
Layer Interaction
There are 3 main flavors of Android layer cake:
  ○ App   Runtime Service   lib
  ○ App   Runtime Service   Native Service   lib
  ○ App   Runtime Service   Native Daemon    lib
Layer Interaction
There are 3 main flavors of Android layer cake:
  ○ App   Runtime Service   lib
  ○ App   Runtime Service   Native Service   lib
  ○ App   Runtime Service   Native Daemon    lib
Android Runtime Services
Android Runtime Services
Android Runtime Services
Android Runtime Services
Example: Location Manager
Layer Interaction
There are 3 main flavors of Android layer cake:
  ○ App   Runtime Service   lib
  ○ App   Runtime Service   Native Service   lib
  ○ App   Runtime Service   Native Daemon    lib
Android Native Services
Android Native Services
Android Native Services
Android Native Services
Android Native Services
Android Native Services
Android Native Services
Layer Interaction
There are 3 main flavors of Android layer cake:
  ○ App   Runtime Service   lib
  ○ App   Runtime Service   Native Service   lib
  ○ App   Runtime Service   Native Daemon    lib
Daemon Connection
Daemon Connection
Daemon Connection
Daemon Connection
Questions

More Related Content

PDF
Low Level View of Android System Architecture
PDF
Embedded Android : System Development - Part I
PDF
Embedded Android : System Development - Part II (HAL)
PDF
Android telephony stack
PDF
Explore Android Internals
PPTX
Android AIDL Concept
PDF
Embedded Android : System Development - Part III (Audio / Video HAL)
PDF
Android device driver structure introduction
Low Level View of Android System Architecture
Embedded Android : System Development - Part I
Embedded Android : System Development - Part II (HAL)
Android telephony stack
Explore Android Internals
Android AIDL Concept
Embedded Android : System Development - Part III (Audio / Video HAL)
Android device driver structure introduction

What's hot (20)

PDF
Embedded Android : System Development - Part IV (Android System Services)
PPTX
Android Booting Sequence
PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
PDF
Android Things : Building Embedded Devices
PDF
Android Treble: Blessing or Trouble?
PPTX
Binder: Android IPC
PDF
Android Internals
PPTX
Android audio system(audioflinger)
PDF
Android ipm 20110409
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PPT
Learning AOSP - Android Booting Process
PPT
Android booting sequece and setup and debugging
PPTX
Android Binder: Deep Dive
ODP
Embedded Android : System Development - Part III
PDF
Android Internals
PPTX
Android internals By Rajesh Khetan
PDF
Accessing Hardware on Android
ODP
Inter-process communication of Android
PDF
Android IPC Mechanism
PDF
Embedded Android Workshop
Embedded Android : System Development - Part IV (Android System Services)
Android Booting Sequence
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Android Things : Building Embedded Devices
Android Treble: Blessing or Trouble?
Binder: Android IPC
Android Internals
Android audio system(audioflinger)
Android ipm 20110409
Embedded Android : System Development - Part II (Linux device drivers)
Learning AOSP - Android Booting Process
Android booting sequece and setup and debugging
Android Binder: Deep Dive
Embedded Android : System Development - Part III
Android Internals
Android internals By Rajesh Khetan
Accessing Hardware on Android
Inter-process communication of Android
Android IPC Mechanism
Embedded Android Workshop
Ad

Viewers also liked (20)

PPTX
Advance ui development and design
PDF
Psi android telephony_case_study_v10
PPTX
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
PPTX
Encrypted Voice Communications
PPTX
Kernel modules
PPTX
Voice encryption for gsm using arduino
PPT
RT Procedure new KTM
PPT
Cellular network
PDF
Linux kernel modules
PDF
Android Telephony Manager and SMS
PPT
5432 cellular network
PDF
Kernel Configuration and Compilation
PPT
Voice securityprotocol review
PDF
RIL and Android Telephony
PPTX
Telephony API
PDF
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
PPTX
Android Layout模組化介紹
PDF
Advance Android Layout Walkthrough
PPT
Android Radio Layer Interface
PPTX
Image encryption and decryption
Advance ui development and design
Psi android telephony_case_study_v10
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
Encrypted Voice Communications
Kernel modules
Voice encryption for gsm using arduino
RT Procedure new KTM
Cellular network
Linux kernel modules
Android Telephony Manager and SMS
5432 cellular network
Kernel Configuration and Compilation
Voice securityprotocol review
RIL and Android Telephony
Telephony API
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
Android Layout模組化介紹
Advance Android Layout Walkthrough
Android Radio Layer Interface
Image encryption and decryption
Ad

Similar to Android presentation (20)

PDF
Android Anatomy google io 2008
PDF
An Introduction To Android
PDF
Improve Android System Component Performance
PPT
Android OS
PPT
My androidpresentation
PDF
Google Android @ AlphaCSP's JavaEdge
PPT
Android Anatomy
PPT
Android platform overview
PPT
Portinig Application, Drivers And Os
PDF
Google Android Naver 1212
PDF
14180203 an-introduction-to-android
PPTX
Android training course
PDF
Ch1 hello, android
PPT
Android architechture
PPTX
Zeelogic android-training-2013
PDF
Android Internals at Linaro Connect Asia 2013
PPTX
Introduction to Android (before 2015)
PPT
Introduction to Android
DOCX
Android..overwiew
Android Anatomy google io 2008
An Introduction To Android
Improve Android System Component Performance
Android OS
My androidpresentation
Google Android @ AlphaCSP's JavaEdge
Android Anatomy
Android platform overview
Portinig Application, Drivers And Os
Google Android Naver 1212
14180203 an-introduction-to-android
Android training course
Ch1 hello, android
Android architechture
Zeelogic android-training-2013
Android Internals at Linaro Connect Asia 2013
Introduction to Android (before 2015)
Introduction to Android
Android..overwiew

Android presentation