SlideShare a Scribd company logo
1 of 117
Android Anatomy and Physiology
Agenda
•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Android Runtime

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   Layer Interaction
Android Anatomy
                                              Applications
 Home              Dialer         SMS/MMS       IM            Browser         Camera         Alarm           Calculator


Contacts       Voice Dial           Email     Calendar       Media Player      Albums        Clock              …


                                    Application Framework
Activity Manager               Window                                           View                 Notification
                               Manager         Content Providers               System                 Manager

                               Telephony                                      Location
Package Manager                 Manager        Resource Manager               Manager                    …


                      Libraries                                                  Android Runtime
Surface Manager                                                                                Core Libraries
                            Media Framework          SQLite

  OpenGL|ES                    FreeType              WebKit                                 Dalvik Virtual Machine


     SGL                          SSL                 Libc

                                              Linux Kernel
 Display Driver              Camera Driver      Bluetooth Driver            Shared Memory       Binder (IPC) Driver
                                                                                 Driver

                                                                               Audio                   Power
  USB Driver                 Keypad Driver        WiFi Driver                  Drivers               Management
Agenda
•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Android Runtime

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   Layer Interaction
Linux Kernel
•   Android is built on the Linux kernel, but Android is not
    Linux

•   No native windowing system

•   No glibc support

•   Does not include the full set of standard Linux utilities



                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Linux Kernel
•   Standard Linux 2.6.24 Kernel

•   Patch of “kernel enhancements” to support Android




                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Why Linux Kernel?
•   Great memory and process management

•   Permissions-based security model

•   Proven driver model

•   Support for shared libraries

•   It!s already open source!


                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Kernel Enhancements
•   Alarm
                                                   •     Low Memory Killer
•   Ashmem
                                                   •     Kernel Debugger
•   Binder
                                                   •     Logger
•   Power Management




                                     Linux Kernel
                                                           Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver          Driver     Binder (IPC) Driver

                                                              Audio             Power
     USB Driver      Keypad Driver      WiFi Driver           Drivers         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




                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
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

                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Binder in Action
Process A          Process B


  App A             Service B
Binder in Action
Process A             Process B


  App A     Context    Service B
Binder in Action
Process A                           Process B


  App A                   Context    Service B
            get service
Binder in Action
Process A                                           Process B


  App A                   Context   Binder Driver    Service B
            get service
            service
Binder in Action
Process A                                           Process B


  App A                   Context   Binder Driver    Service B
            get service
            service
Binder in Action
Process A                                                     Process B


  App A                   Context             Binder Driver    Service B
            get service
            service
                                call foo(object)
Binder in Action
Process A                                                               Process B


  App A                   Context                Binder Driver           Service B
            get service
            service
                                    call foo(object)    marshal proxy
                                                        object
Binder in Action
Process A                                                               Process B


  App A                   Context                Binder Driver           Service B
            get service
            service
                                    call foo(object)    marshal proxy
                                                        object

                                                        relay to
                                                        IPC threads
Binder in Action
Process A                                                                Process B


  App A                   Context                 Binder Driver           Service B
            get service
            service

                                    call foo(object)     marshal proxy
                                                         object

                                                         relay to
                                                         IPC threads




                                    call return
Binder


Android Interface Definition Language (AIDL)
•   http://code.google.com/android/reference/aidl.html

                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
PM Problem

•     Mobile devices run on battery power

•     Batteries have limited capacity




                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
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



                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Android PM in Action
 App A    PowerManager   PM Driver
Android PM in Action
 App A                   PowerManager   PM Driver
         new wake lock

         PARTIAL
Android PM in Action
 App A                   PowerManager                 PM Driver
         new wake lock

         PARTIAL                   create wake lock
Android PM in Action
 App A                   PowerManager                 PM Driver
         new wake lock

         PARTIAL                   create wake lock


                                                                  Turn off
                                                                  LCD
Android PM in Action
 App A                   PowerManager                 PM Driver
         new wake lock

         PARTIAL                   create wake lock


                                                                  Turn off
                                                                  LCD

            release

                                   release
Android PM in Action
 App A                   PowerManager                 PM Driver
         new wake lock

         PARTIAL                   create wake lock


                                                                  Turn off
                                                                  LCD

            release

                                   release

                                                                  Turn off
                                                                  CPU
Android PM

android.os.PowerManager
•     Use wake locks carefully!


•     userActivity(long when, …);


                                     Linux Kernel
                                                         Shared Memory
    Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                            Audio             Power
     USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Kernel
The Android kernel source is available today
at:


                   http://git.android.com

                                  Linux Kernel
                                                      Shared Memory
 Display Driver   Camera Driver    Bluetooth Driver        Driver     Binder (IPC) Driver

                                                         Audio             Power
  USB Driver      Keypad Driver      WiFi Driver         Drivers         Management
Agenda
•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Android Runtime

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   Layer Interaction
Android Anatomy



                  Libraries
Surface Manager    Media Framework        SQLite

  OpenGL|ES           FreeType            WebKit


     SGL                 SSL                Libc

                                     Linux Kernel
 Display Driver     Camera Driver     Bluetooth Driver   Shared Memory   Binder (IPC) Driver
                                                              Driver

                                                            Audio             Power
  USB Driver        Keypad Driver       WiFi Driver         Drivers         Management
Native Libraries
•   Bionic Libc

•   Function Libraries

•   Native Servers

•   Hardware Abstraction Libraries




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Native Libraries
•   Bionic Libc

•   Function Libraries

•   Native Servers

•   Hardware Abstraction Libraries




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
What is Bionic?
•   What is bionic?
    •      Custom libc implementation, optimized for embedded use.




                                            Libraries
        Surface Manager   Media Framework     SQLite     WebKit   Libc

          OpenGL|ES        Audio Manager      FreeType    SSL     …
Why 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




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Bionic libc
•   BSD License

•   Small size and fast code paths

•   Very fast and small custom pthread implementation




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Bionic libc
•   Built-in support for important Android-specific services
    •        system properties
         "     getprop(“my.system.property”, buff, default);

    •        log capabilities
         !     LOGI(“Logging a message with priority ‘Info’”);


                                            Libraries
        Surface Manager   Media Framework     SQLite     WebKit   Libc

          OpenGL|ES        Audio Manager      FreeType    SSL     …
Bionic libc
•   Doesn't support certain POSIX features

•   Not compatible with Gnu Libc (glibc)

•   All native code must be compiled against bionic




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Native Libraries
•   Bionic Libc

•   Function Libraries

•   Native Servers

•   Hardware Abstraction Libraries




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
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


                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Media Framework
•   Based on PacketVideo OpenCORE platform

•   Supports standard video, audio, still-frame formats

•   Support for hardware / software codec plug-ins




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
SQLite
•   Light-weight transactional data store

•   Back end for most platform data storage




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Native Libraries
•   Bionic Libc

•   Function Libraries

•   Native Servers

•   Hardware Abstraction Libraries




                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Surface Flinger
                           Surface
       App
                           Surface                                     Frame
                                            Surface Flinger            Buffer
       App
                           Surface


•   Provides system-wide surface “composer”, handling all surface
    rendering to frame buffer device

•   Can combine 2D and 3D surfaces and surfaces from multiple
    applications

                                        Libraries
    Surface Manager   Media Framework     SQLite              WebKit            Libc

      OpenGL|ES        Audio Manager      FreeType             SSL              …
Surface Flinger
•   Surfaces passed as buffers via Binder IPC calls

•   Can use OpenGL ES and 2D hardware accelerator for its
    compositions

•   Double-buffering using page-flip



                                        Libraries
    Surface Manager   Media Framework     SQLite     WebKit   Libc

      OpenGL|ES        Audio Manager      FreeType    SSL     …
Audio Flinger
                          Tone                                       Earpeace
                          Audio
    App
                         Media
                         Player             Audio Flinger            Speaker
    App
                       Game Audio                                    Bluetooth



•   Manages all audio output devices

•   Processes multiple audio streams into PCM audio out paths

•   Handles audio routing to various outputs
                                         Libraries
     Surface Manager   Media Framework     SQLite           WebKit           Libc

       OpenGL|ES        Audio Manager      FreeType          SSL               …
Native Libraries
•   Bionic Libc

•   Function Libraries

•   Native Servers

•   Hardware Abstraction Libraries




                                        Libraries
    Surface Manager   Media Framework     SQLite     LibWebCore   Libc

      OpenGL|ES        Audio Manager      FreeType      SSL       …
Hardware Abstraction Layer
                                              Applications
  Home              Dialer        SMS/MMS        IM          Browser        Camera        Alarm           Calculator


 Contacts       Voice Dial          Email     Calendar     Media Player   Photo Album     Clock               …


                                    Application Framework
 Activity Manager              Window                                         View                Notification
                               Manager          Content Providers            System                Manager

                               Telephony                                    Location
 Package Manager                Manager         Resource Manager            Manager                   …


                             Libraries                                         Android Runtime
 Surface         Media                                                                       Core Libraries
 Manager      Framework           SQLite      WebKit             Libc

                 Audio
OpenGL|ES       Manager          FreeType       SSL              …                        Dalvik Virtual Machine

                                   Hardware Abstraction Layer
Graphics           Audio         Camera      Bluetooth           GPS      Radio (RIL)     WiFi              …

                                             Linux Kernel
                                                                          Shared Memory
  Display Driver             Camera Driver      Bluetooth Driver               Driver        Binder (IPC) Driver

                                                                             Audio                  Power
   USB Driver                Keypad Driver         WiFi Driver               Drivers              Management
Hardware Abstraction Libraries
•    User space C/C++ library layer

•    Defines the interface that Android requires hardware
     “drivers” to implement

•    Separates the Android platform logic from the hardware
     interface




                        Hardware Abstraction Layer
    Graphics   Audio   Camera   Bluetooth   GPS   Radio (RIL)   WiFi   …
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 Layer
 Graphics   Audio   Camera   Bluetooth   GPS   Radio (RIL)   WiFi   …
HAL Header Example
// must be provided by each Acme hardware implementation
typedef struct {
       int     (*foo)( void );
!    char      (*bar)( void );
!    …
!
} AcmeFunctions;


const AcmeFunctions *Acme_Init(const struct Env *env, int argc, char
   **argv);




                         Hardware Abstraction Layer
    Graphics    Audio   Camera   Bluetooth   GPS   Radio (RIL)   WiFi   …
Hardware Abstraction Libraries
•    Libraries are loaded dynamically at runtime as needed
         dlHandle = dlopen(“/system/lib/libacme.so”, RTLD_NOW);

         ...

         acmeInit = (const AcmeFunctions *(*)(const struct Env *,
            int, char **))dlsym(dlHandle, ”Acme_Init");

         ...

         acmeFuncs = acmeInit(&env, argc, argv);




                        Hardware Abstraction Layer
    Graphics   Audio   Camera   Bluetooth   GPS   Radio (RIL)   WiFi   …
Agenda
•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Android Runtime

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   Layer Interaction
Android Anatomy



                  Libraries                                   Android Runtime
Surface Manager                                                             Core Libraries
                   Media Framework        SQLite

  OpenGL|ES           FreeType            WebKit                         Dalvik Virtual Machine


     SGL                 SSL                Libc

                                     Linux Kernel
 Display Driver     Camera Driver     Bluetooth Driver   Shared Memory       Binder (IPC) Driver
                                                              Driver

                                                            Audio                  Power
  USB Driver        Keypad Driver       WiFi Driver         Drivers              Management
Dalvik Virtual Machine
•   Android!s custom clean-room implementation 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


                       Android Runtime
                                 Core Libraries


                              Dalvik Virtual Machine
Dalvik Virtual Machine
•   Designed for embedded environment
    •   Supports multiple virtual machine processes per device

    •   Highly CPU-optimized bytecode interpreter

    •   Uses runtime memory very efficiently




                     Android Runtime
                               Core Libraries


                            Dalvik Virtual Machine
Core Libraries
•   Core APIs for Java language provide a powerful, yet
    simple and familiar development platform
     •   Data structures

     •   Utilities

     •   File access

     •   Network Access

     •   Graphics

     •   …
                       Android Runtime
                              Core Libraries


                           Dalvik Virtual Machine
Agenda

•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Android Runtime

    •   Application Framework

•   Android Physiology

    •   Start-up Walkthrough

    •   Layer Interaction
Android Anatomy

                           Application Framework
Activity Manager      Window                                 View               Notification
                      Manager        Content Providers      System               Manager

                      Telephony                            Location
Package Manager        Manager       Resource Manager      Manager                  …

                    Libraries                                 Android Runtime
Surface Manager                                                             Core Libraries
                   Media Framework        SQLite

  OpenGL|ES           FreeType            WebKit                         Dalvik Virtual Machine


     SGL                 SSL                Libc

                                     Linux Kernel
 Display Driver     Camera Driver     Bluetooth Driver   Shared Memory       Binder (IPC) Driver
                                                              Driver

                                                            Audio                  Power
  USB Driver        Keypad Driver       WiFi Driver         Drivers              Management
Core Platform Services
•   Services that are essential to the Android platform

•   Behind the scenes - applications typically don!t access them
    directly




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager

•   Package Manager




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager

•   Package Manager

•   Window Manager




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager

•   Package Manager

•   Window Manager

•   Resource Manager




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager

•   Package Manager

•   Window Manager

•   Resource Manager

•   Content Providers



                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Core Platform Services
•   Activity Manager

•   Package Manager

•   Window Manager

•   Resource Manager

•   Content Providers

•   View System

                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Provide access to lower-level hardware APIs




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Provide access to lower-level hardware APIs

•   Typically accessed through local Manager object


LocationManager lm = (LocationManager)
   Context.getSystemService(Context.LOCATION_SERVICE);




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service

•   Location Service




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service

•   Location Service

•   Bluetooth Service




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service

•   Location Service

•   Bluetooth Service

•   WiFi Service




                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service

•   Location Service

•   Bluetooth Service

•   WiFi Service

•   USB Service



                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Hardware Services
•   Telephony Service

•   Location Service

•   Bluetooth Service

•   WiFi Service

•   USB Service

•   Sensor Service

                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Application Framework
More Information

•   At Google I/O
    •    “Inside the Android Application Framework”

•   Online
    •    http://code.google.com/android

                            Application Framework
    Activity Manager   Window                           View      Notification
                       Manager     Content Providers   System      Manager

                       Telephony                       Location
    Package Manager     Manager    Resource Manager    Manager       …
Android Anatomy
                                              Applications
 Home              Dialer         SMS/MMS       IM            Browser         Camera         Alarm           Calculator


Contacts       Voice Dial           Email     Calendar       Media Player      Albums        Clock              …


                                    Application Framework
Activity Manager               Window                                           View                 Notification
                               Manager         Content Providers               System                 Manager

                               Telephony                                      Location
Package Manager                 Manager        Resource Manager               Manager                    …


                      Libraries                                                  Android Runtime
Surface Manager                                                                                Core Libraries
                            Media Framework          SQLite

  OpenGL|ES                    FreeType              WebKit                                 Dalvik Virtual Machine


     SGL                          SSL                 Libc

                                              Linux Kernel
 Display Driver              Camera Driver      Bluetooth Driver            Shared Memory       Binder (IPC) Driver
                                                                                 Driver

                                                                               Audio                   Power
  USB Driver                 Keypad Driver        WiFi Driver                  Drivers               Management
Agenda

•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   Layer Interaction
Agenda

•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Application Framework

•   Android Physiology
    •   Start-up Walkthrough

    •   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.




                               Init


                           Linux Kernel
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




  usbd        adbd          debuggerd   rild



                     Init
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




 usbd
  adbd
debuggerd
 daemons                           Zygote



                    Init
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



                 Service
                 Manager

 usbd
  adbd
debuggerd
 daemons         runtime        Zygote



                   Init
Runtime Walkthrough
Runtime process sends request for Zygote to start System
Service




              Service
              Manager

 usbd
  adbd
debuggerd
 daemons      runtime        Zygote



                Init
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




                  Service                          System
                  Manager                          Server
 usbd
  adbd
debuggerd
 daemons          runtime          Zygote         Dalvik VM



                    Init
Runtime Walkthrough
System Service starts the native system servers, including:
•   Surface Flinger

•   Audio Flinger


                                         Audio Flinger

                                           Surface
                                           Flinger

                      Service               System
                      Manager               Server
 usbd
  adbd
debuggerd
 daemons              runtime   Zygote    Dalvik VM



                        Init
Runtime Walkthrough
Native system servers register with Service Manager as IPC
service targets:




                                      Audio Flinger

                                        Surface
                                        Flinger

               Service                   System
               Manager                   Server
 usbd
  adbd
debuggerd
 daemons       runtime     Zygote      Dalvik VM



                 Init
Runtime Walkthrough
System Service starts the Android managed services:
     Content   Telephony   Bluetooth    Connectivity    Location
     Manager    Service     Service       Service       Manager
     Window     Activity    Package       Power
     Manager    Manager    Manager       Manager            …


                                                   Camera
                                                  Surface
                                                    Service
                                                  Flinger

                Service                           System
                Manager                           Server
 usbd
  adbd
debuggerd
 daemons        runtime        Zygote           Dalvik VM



                  Init
Runtime Walkthrough
Android managed Services register with Service Manager:
     Content   Telephony   Bluetooth    Connectivity    Location
     Manager    Service     Service       Service       Manager
     Window     Activity    Package       Power
     Manager    Manager    Manager       Manager            …


                           Service
                            Camera
                           Manager
                            Service                Camera
                                                  Surface
                                                    Service
                                                  Flinger

                Service                           System
                Manager                           Server
 usbd
  adbd
debuggerd
 daemons        runtime        Zygote           Dalvik VM



                  Init
Runtime Walkthrough


                                      …
                                   Power
                                 Manager
                               Activity
                               Manager

                                 Camera
                                Surface
                                  Service
                                Flinger

            Service             System
            Manager             Server
 usbd
  adbd
debuggerd
 daemons    runtime   Zygote   Dalvik VM



              Init
Runtime Walkthrough
After system server loads all services, the system is ready…
 Init     Daemon       runtime   Zygote   System
         Processes                        Server


                                          Activity
                                          Manager
                                          Package
                                          Manager
                                          Window
                                          Manager
                                             …

                                          Dalvik VM
                                           Surface
                                           Flinger
            usbd
             adbd
  Init     debuggerd
            daemons    runtime   Zygote     Audio
                                           Flinger
Runtime Walkthrough
After system server loads all services, the system is ready…
 Init     Daemon       runtime   Zygote   System       Home
         Processes                        Server

                                                       Home
                                          Activity
                                          Manager     Dalvik VM
                                          Package
                                          Manager
                                          Window
                                          Manager
                                             …

                                          Dalvik VM
                                           Surface
                                           Flinger
            usbd
             adbd
  Init     debuggerd
            daemons    runtime   Zygote     Audio
                                           Flinger
Runtime Walkthrough
After system server loads all services, the system is ready…
 Init     Daemon       runtime   Zygote   System       Home
         Processes                        Server

                                          Activity     Home
                                          Manager
                                          Package     Dalvik VM
                                          Manager
                                          Window
                                          Manager
                                             …

                                          Dalvik VM
                                           Surface
                                           Flinger
            usbd
             adbd
  Init     debuggerd
            daemons    runtime   Zygote     Audio
                                           Flinger
 libc         libc       libc     libc      libc         libc
Runtime Walkthrough
Each subsequent application is launched in it!s own process
   Daemon      runtime   Zygote   System       Home       Contacts
  Processes                       Server

                                  Activity     Home        Contacts
                                  Manager
                                  Package     Dalvik VM   Dalvik VM
                                  Manager
                                  Window
                                  Manager
                                     …

                                  Dalvik VM
                                   Surface
                                   Flinger
    usbd
     adbd
   debuggerd
    daemons    runtime   Zygote     Audio
                                   Flinger
      libc       libc     libc      libc         libc        libc
Agenda

•   Android Anatomy
    •   Linux Kernel

    •   Native Libraries

    •   Framework Services

•   Android Physiology
    •   Start-up Walkthrough

    •   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
Applications
               Application
                             Binder IPC

Application Framework

                                          Runtime Service


Libraries




Linux Kernel

                                           Kernel Driver
Android Runtime Services
Applications
               Application
                             Binder IPC

Application Framework

                                          Runtime Service

                                                   JNI

Libraries
                                    Native Service Binding




Linux Kernel

                                           Kernel Driver
Android Runtime Services
Applications
               Application
                             Binder IPC

Application Framework

                                          Runtime Service

                                                   JNI

Libraries
                                    Native Service Binding

                                                   Dynamic load


                                           HAL Library


Linux Kernel

                                           Kernel Driver
Android Runtime Services
Applications
               Application
                             Binder IPC

Application Framework

                                          Runtime Service

                                                   JNI

Libraries
                                    Native Service Binding

                                                   Dynamic load


                                           HAL Library


Linux Kernel

                                           Kernel Driver
Example: Location Manager
Applications
                             Binder IPC
               Application

Application Framework
                                  Location Manager Service


                                     GpsLocationProvider
                                                  JNI
Libraries
                                     GpsLocationProvider
                                                  Dynamic load


                                            libgps.so

Linux Kernel

                                          Kernel Driver
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
Applications

              Application
Application
Framework                     Runtime
                              Service
                                    JNI
Libraries
                            Native Service
                               Binding




Linux Kernel
Android Native Services
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                                           Binder IPC
                          Native Service                Native Service
                             Binding




Linux Kernel
Android Native Services
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                                           Binder IPC
                          Native Service                Native Service
                             Binding
                                                                Dynamic load


                                                         HAL Library




Linux Kernel
Android Native Services
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                                           Binder IPC
                          Native Service                Native Service
                             Binding
                                                                Dynamic load


                                                         HAL Library




Linux Kernel

                                                        Kernel Driver
Android Native Services
Applications

            Application
 Application
Framework                 MediaPlayer
                                 JNI
Libraries
                                        Binder IPC
                          MediaPlayer                AudioFlinger
                                                             Dynamic load

                             Media
                          Framework                   libaudio.so




Linux Kernel
                                                     Kernel Driver
Android Native Services
Applications

            Application
 Application
Framework                 MediaPlayer
                                 JNI
Libraries
                                        Binder IPC
                          MediaPlayer                AudioFlinger
                                                             Dynamic load

                             Media                    libaudio.so
                          Framework


                                                        ALSA

Linux Kernel
                                                     Kernel Driver
Android Native Services
Applications

            Application
 Application
Framework                 MediaPlayer
                                 JNI
Libraries
                                        Binder IPC
                          MediaPlayer                AudioFlinger
                                                             Dynamic load

                             Media                    libaudio.so
                          Framework


                                                      Proprietary
                                                     Audio Driver
Linux Kernel
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
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                          Native Service
                             Binding




Linux Kernel

                                           Kernel Driver
Daemon Connection
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                                           sockets
                          Native Service               Daemon
                             Binding




Linux Kernel

                                                     Kernel Driver
Daemon Connection
Applications

            Application
 Application
Framework                   Runtime
                            Service
                                  JNI
Libraries
                                           sockets
                          Native Service               Daemon
                             Binding
                                                             Dynamic load


                                                     HAL Library




Linux Kernel

                                                     Kernel Driver
Daemon Connection
Applications

            Application
 Application
Framework                 Telephony Manager
                                   JNI
Libraries
                                              sockets
                              Telephony                      rild
                               Manager
                                                                    Dynamic load


                                                           libril.so




Linux Kernel

                                                        Kernel Driver
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 Anatomy
                                              Applications
 Home              Dialer         SMS/MMS       IM            Browser         Camera         Alarm           Calculator


Contacts       Voice Dial           Email     Calendar       Media Player      Albums        Clock              …


                                    Application Framework
Activity Manager               Window                                           View                 Notification
                               Manager         Content Providers               System                 Manager

                               Telephony                                      Location
Package Manager                 Manager        Resource Manager               Manager                    …


                      Libraries                                                  Android Runtime
Surface Manager                                                                                Core Libraries
                            Media Framework          SQLite

  OpenGL|ES                    FreeType              WebKit                                 Dalvik Virtual Machine


     SGL                          SSL                 Libc

                                              Linux Kernel
 Display Driver              Camera Driver      Bluetooth Driver            Shared Memory       Binder (IPC) Driver
                                                                                 Driver

                                                                               Audio                   Power
  USB Driver                 Keypad Driver        WiFi Driver                  Drivers               Management

More Related Content

What's hot

Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
 
IPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseIPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseYonatan Levin
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting SequenceJayanta Ghoshal
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for LinuxYu-Hsin Hung
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Marakana Android Internals
Marakana Android InternalsMarakana Android Internals
Marakana Android InternalsMarko Gargenta
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Tetsuyuki Kobayashi
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developersHassan Abid
 

What's hot (20)

Binder: Android IPC
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
 
Reverse Engineering Android Application
Reverse Engineering Android ApplicationReverse Engineering Android Application
Reverse Engineering Android Application
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
IPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curseIPC: AIDL is sexy, not a curse
IPC: AIDL is sexy, not a curse
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Marakana Android Internals
Marakana Android InternalsMarakana Android Internals
Marakana Android Internals
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developers
 

Viewers also liked

Viewers also liked (20)

Android Anatomy
Android  AnatomyAndroid  Anatomy
Android Anatomy
 
Oficio capcitación matemática
Oficio capcitación matemáticaOficio capcitación matemática
Oficio capcitación matemática
 
Oficio capcitación matemática
Oficio capcitación matemáticaOficio capcitación matemática
Oficio capcitación matemática
 
20分で理解するdisplaysystem
20分で理解するdisplaysystem20分で理解するdisplaysystem
20分で理解するdisplaysystem
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
 
LiquidPub: Services at Service of Science
LiquidPub: Services at Service of ScienceLiquidPub: Services at Service of Science
LiquidPub: Services at Service of Science
 
Accessible Blackboard Part 2
Accessible Blackboard Part 2Accessible Blackboard Part 2
Accessible Blackboard Part 2
 
Morigi massimo 15102011_b
Morigi massimo 15102011_bMorigi massimo 15102011_b
Morigi massimo 15102011_b
 
Assistive Technology Web Quest
Assistive Technology Web QuestAssistive Technology Web Quest
Assistive Technology Web Quest
 
2011 Small Business Presentation for HAUL
2011 Small Business Presentation for HAUL2011 Small Business Presentation for HAUL
2011 Small Business Presentation for HAUL
 
Chapter 2 1
Chapter 2 1Chapter 2 1
Chapter 2 1
 
Economic presentation
Economic presentationEconomic presentation
Economic presentation
 
2010 Smalll Business Presentation for HAUL
2010 Smalll Business Presentation for HAUL2010 Smalll Business Presentation for HAUL
2010 Smalll Business Presentation for HAUL
 
Building Online Learning Environments
Building Online Learning EnvironmentsBuilding Online Learning Environments
Building Online Learning Environments
 
New zealand jeopardy
New zealand jeopardyNew zealand jeopardy
New zealand jeopardy
 
College 1 6
College 1 6College 1 6
College 1 6
 
Day 1
Day 1Day 1
Day 1
 
Aguila
AguilaAguila
Aguila
 
Peer Review in the LiquidPub project
Peer Review in the LiquidPub projectPeer Review in the LiquidPub project
Peer Review in the LiquidPub project
 

Similar to The anatomy and philosophy of Android - Google I/O 2009

An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To AndroidGoogleTecTalks
 
Google Io Introduction To Android
Google Io Introduction To AndroidGoogle Io Introduction To Android
Google Io Introduction To AndroidBhavya Siddappa
 
Android Anatomy google io 2008
Android Anatomy google io 2008Android Anatomy google io 2008
Android Anatomy google io 2008Trinh Duy Hung
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010Marko Gargenta
 
Android: A 9,000-foot Overview
Android: A 9,000-foot OverviewAndroid: A 9,000-foot Overview
Android: A 9,000-foot OverviewMarko Gargenta
 
Android For Managers Slides
Android For Managers SlidesAndroid For Managers Slides
Android For Managers SlidesMarko Gargenta
 
Android for Java Developers
Android for Java DevelopersAndroid for Java Developers
Android for Java DevelopersMarko Gargenta
 
Android application development
Android application developmentAndroid application development
Android application developmentLinh Vi Tường
 
Introduction to ICS
Introduction to ICSIntroduction to ICS
Introduction to ICSamsanjeev
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture PortfolioMajong DevJfu
 
Tacademy techclinic-2012-07-11
Tacademy techclinic-2012-07-11Tacademy techclinic-2012-07-11
Tacademy techclinic-2012-07-11영호 라
 
Open Cloud Interop Public
Open Cloud Interop PublicOpen Cloud Interop Public
Open Cloud Interop Publicrvanhoe
 
Eci Mobile Computing 20120724 Bryantafel
Eci   Mobile Computing 20120724   BryantafelEci   Mobile Computing 20120724   Bryantafel
Eci Mobile Computing 20120724 BryantafelBryan Tafel
 
Android platform
Android platformAndroid platform
Android platformmaya_slides
 
Brief about Windows Azure Platform
Brief about Windows Azure Platform Brief about Windows Azure Platform
Brief about Windows Azure Platform K.Mohamed Faizal
 
Linux on System z Update: Current & Future Linux on System z Technology
Linux on System z Update: Current & Future Linux on System z TechnologyLinux on System z Update: Current & Future Linux on System z Technology
Linux on System z Update: Current & Future Linux on System z TechnologyIBM India Smarter Computing
 
Portinig Application, Drivers And Os
Portinig Application, Drivers And OsPortinig Application, Drivers And Os
Portinig Application, Drivers And Osmomobangalore
 

Similar to The anatomy and philosophy of Android - Google I/O 2009 (20)

An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
Google Io Introduction To Android
Google Io Introduction To AndroidGoogle Io Introduction To Android
Google Io Introduction To Android
 
Android Anatomy google io 2008
Android Anatomy google io 2008Android Anatomy google io 2008
Android Anatomy google io 2008
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010
 
Open Android
Open AndroidOpen Android
Open Android
 
Android and Intel Inside
Android and Intel InsideAndroid and Intel Inside
Android and Intel Inside
 
Android: A 9,000-foot Overview
Android: A 9,000-foot OverviewAndroid: A 9,000-foot Overview
Android: A 9,000-foot Overview
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android For Managers Slides
Android For Managers SlidesAndroid For Managers Slides
Android For Managers Slides
 
Android for Java Developers
Android for Java DevelopersAndroid for Java Developers
Android for Java Developers
 
Android application development
Android application developmentAndroid application development
Android application development
 
Introduction to ICS
Introduction to ICSIntroduction to ICS
Introduction to ICS
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio
 
Tacademy techclinic-2012-07-11
Tacademy techclinic-2012-07-11Tacademy techclinic-2012-07-11
Tacademy techclinic-2012-07-11
 
Open Cloud Interop Public
Open Cloud Interop PublicOpen Cloud Interop Public
Open Cloud Interop Public
 
Eci Mobile Computing 20120724 Bryantafel
Eci   Mobile Computing 20120724   BryantafelEci   Mobile Computing 20120724   Bryantafel
Eci Mobile Computing 20120724 Bryantafel
 
Android platform
Android platformAndroid platform
Android platform
 
Brief about Windows Azure Platform
Brief about Windows Azure Platform Brief about Windows Azure Platform
Brief about Windows Azure Platform
 
Linux on System z Update: Current & Future Linux on System z Technology
Linux on System z Update: Current & Future Linux on System z TechnologyLinux on System z Update: Current & Future Linux on System z Technology
Linux on System z Update: Current & Future Linux on System z Technology
 
Portinig Application, Drivers And Os
Portinig Application, Drivers And OsPortinig Application, Drivers And Os
Portinig Application, Drivers And Os
 

More from Viswanath J

Introduction to Consul
Introduction to ConsulIntroduction to Consul
Introduction to ConsulViswanath J
 
Getting started with Cassandra 2.1
Getting started with Cassandra 2.1Getting started with Cassandra 2.1
Getting started with Cassandra 2.1Viswanath J
 
Introduction to NOSQL quadrants
Introduction to NOSQL quadrantsIntroduction to NOSQL quadrants
Introduction to NOSQL quadrantsViswanath J
 
Improving effectiveness of a meeting
Improving effectiveness of a meetingImproving effectiveness of a meeting
Improving effectiveness of a meetingViswanath J
 
Inside the Android application framework - Google I/O 2009
Inside the Android application framework - Google I/O 2009Inside the Android application framework - Google I/O 2009
Inside the Android application framework - Google I/O 2009Viswanath J
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?Viswanath J
 
Introduction To Docbook 4 .5 Authoring
Introduction To Docbook 4 .5   AuthoringIntroduction To Docbook 4 .5   Authoring
Introduction To Docbook 4 .5 AuthoringViswanath J
 

More from Viswanath J (8)

Introduction to Consul
Introduction to ConsulIntroduction to Consul
Introduction to Consul
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Getting started with Cassandra 2.1
Getting started with Cassandra 2.1Getting started with Cassandra 2.1
Getting started with Cassandra 2.1
 
Introduction to NOSQL quadrants
Introduction to NOSQL quadrantsIntroduction to NOSQL quadrants
Introduction to NOSQL quadrants
 
Improving effectiveness of a meeting
Improving effectiveness of a meetingImproving effectiveness of a meeting
Improving effectiveness of a meeting
 
Inside the Android application framework - Google I/O 2009
Inside the Android application framework - Google I/O 2009Inside the Android application framework - Google I/O 2009
Inside the Android application framework - Google I/O 2009
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?
 
Introduction To Docbook 4 .5 Authoring
Introduction To Docbook 4 .5   AuthoringIntroduction To Docbook 4 .5   Authoring
Introduction To Docbook 4 .5 Authoring
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

The anatomy and philosophy of Android - Google I/O 2009

  • 1. Android Anatomy and Physiology
  • 2. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Android Runtime • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 3. Android Anatomy Applications Home Dialer SMS/MMS IM Browser Camera Alarm Calculator Contacts Voice Dial Email Calendar Media Player Albums Clock … Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager … Libraries Android Runtime Surface Manager Core Libraries Media Framework SQLite OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 4. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Android Runtime • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 5. Linux Kernel • Android is built on the Linux kernel, but Android is not Linux • No native windowing system • No glibc support • Does not include the full set of standard Linux utilities Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 6. Linux Kernel • Standard Linux 2.6.24 Kernel • Patch of “kernel enhancements” to support Android Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 7. Why Linux Kernel? • Great memory and process management • Permissions-based security model • Proven driver model • Support for shared libraries • It!s already open source! Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 8. Kernel Enhancements • Alarm • Low Memory Killer • Ashmem • Kernel Debugger • Binder • Logger • Power Management Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 9. 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 Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 10. 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 Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 11. Binder in Action Process A Process B App A Service B
  • 12. Binder in Action Process A Process B App A Context Service B
  • 13. Binder in Action Process A Process B App A Context Service B get service
  • 14. Binder in Action Process A Process B App A Context Binder Driver Service B get service service
  • 15. Binder in Action Process A Process B App A Context Binder Driver Service B get service service
  • 16. Binder in Action Process A Process B App A Context Binder Driver Service B get service service call foo(object)
  • 17. Binder in Action Process A Process B App A Context Binder Driver Service B get service service call foo(object) marshal proxy object
  • 18. Binder in Action Process A Process B App A Context Binder Driver Service B get service service call foo(object) marshal proxy object relay to IPC threads
  • 19. Binder in Action Process A Process B App A Context Binder Driver Service B get service service call foo(object) marshal proxy object relay to IPC threads call return
  • 20. Binder Android Interface Definition Language (AIDL) • http://code.google.com/android/reference/aidl.html Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 21. PM Problem • Mobile devices run on battery power • Batteries have limited capacity Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 22. 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 Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 23. Android PM in Action App A PowerManager PM Driver
  • 24. Android PM in Action App A PowerManager PM Driver new wake lock PARTIAL
  • 25. Android PM in Action App A PowerManager PM Driver new wake lock PARTIAL create wake lock
  • 26. Android PM in Action App A PowerManager PM Driver new wake lock PARTIAL create wake lock Turn off LCD
  • 27. Android PM in Action App A PowerManager PM Driver new wake lock PARTIAL create wake lock Turn off LCD release release
  • 28. Android PM in Action App A PowerManager PM Driver new wake lock PARTIAL create wake lock Turn off LCD release release Turn off CPU
  • 29. Android PM android.os.PowerManager • Use wake locks carefully! • userActivity(long when, …); Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 30. Kernel The Android kernel source is available today at: http://git.android.com Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 31. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Android Runtime • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 32. Android Anatomy Libraries Surface Manager Media Framework SQLite OpenGL|ES FreeType WebKit SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 33. Native Libraries • Bionic Libc • Function Libraries • Native Servers • Hardware Abstraction Libraries Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 34. Native Libraries • Bionic Libc • Function Libraries • Native Servers • Hardware Abstraction Libraries Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 35. What is Bionic? • What is bionic? • Custom libc implementation, optimized for embedded use. Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 36. Why 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 Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 37. Bionic libc • BSD License • Small size and fast code paths • Very fast and small custom pthread implementation Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 38. Bionic libc • Built-in support for important Android-specific services • system properties " getprop(“my.system.property”, buff, default); • log capabilities ! LOGI(“Logging a message with priority ‘Info’”); Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 39. Bionic libc • Doesn't support certain POSIX features • Not compatible with Gnu Libc (glibc) • All native code must be compiled against bionic Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 40. Native Libraries • Bionic Libc • Function Libraries • Native Servers • Hardware Abstraction Libraries Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 41. 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 Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 42. Media Framework • Based on PacketVideo OpenCORE platform • Supports standard video, audio, still-frame formats • Support for hardware / software codec plug-ins Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 43. SQLite • Light-weight transactional data store • Back end for most platform data storage Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 44. Native Libraries • Bionic Libc • Function Libraries • Native Servers • Hardware Abstraction Libraries Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 45. Surface Flinger Surface App Surface Frame Surface Flinger Buffer App Surface • Provides system-wide surface “composer”, handling all surface rendering to frame buffer device • Can combine 2D and 3D surfaces and surfaces from multiple applications Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 46. Surface Flinger • Surfaces passed as buffers via Binder IPC calls • Can use OpenGL ES and 2D hardware accelerator for its compositions • Double-buffering using page-flip Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 47. Audio Flinger Tone Earpeace Audio App Media Player Audio Flinger Speaker App Game Audio Bluetooth • Manages all audio output devices • Processes multiple audio streams into PCM audio out paths • Handles audio routing to various outputs Libraries Surface Manager Media Framework SQLite WebKit Libc OpenGL|ES Audio Manager FreeType SSL …
  • 48. Native Libraries • Bionic Libc • Function Libraries • Native Servers • Hardware Abstraction Libraries Libraries Surface Manager Media Framework SQLite LibWebCore Libc OpenGL|ES Audio Manager FreeType SSL …
  • 49. Hardware Abstraction Layer Applications Home Dialer SMS/MMS IM Browser Camera Alarm Calculator Contacts Voice Dial Email Calendar Media Player Photo Album Clock … Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager … Libraries Android Runtime Surface Media Core Libraries Manager Framework SQLite WebKit Libc Audio OpenGL|ES Manager FreeType SSL … Dalvik Virtual Machine Hardware Abstraction Layer Graphics Audio Camera Bluetooth GPS Radio (RIL) WiFi … Linux Kernel Shared Memory Display Driver Camera Driver Bluetooth Driver Driver Binder (IPC) Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 50. Hardware Abstraction Libraries • User space C/C++ library layer • Defines the interface that Android requires hardware “drivers” to implement • Separates the Android platform logic from the hardware interface Hardware Abstraction Layer Graphics Audio Camera Bluetooth GPS Radio (RIL) WiFi …
  • 51. 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 Layer Graphics Audio Camera Bluetooth GPS Radio (RIL) WiFi …
  • 52. HAL Header Example // must be provided by each Acme hardware implementation typedef struct { int (*foo)( void ); ! char (*bar)( void ); ! … ! } AcmeFunctions; const AcmeFunctions *Acme_Init(const struct Env *env, int argc, char **argv); Hardware Abstraction Layer Graphics Audio Camera Bluetooth GPS Radio (RIL) WiFi …
  • 53. Hardware Abstraction Libraries • Libraries are loaded dynamically at runtime as needed dlHandle = dlopen(“/system/lib/libacme.so”, RTLD_NOW); ... acmeInit = (const AcmeFunctions *(*)(const struct Env *, int, char **))dlsym(dlHandle, ”Acme_Init"); ... acmeFuncs = acmeInit(&env, argc, argv); Hardware Abstraction Layer Graphics Audio Camera Bluetooth GPS Radio (RIL) WiFi …
  • 54. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Android Runtime • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 55. Android Anatomy Libraries Android Runtime Surface Manager Core Libraries Media Framework SQLite OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 56. Dalvik Virtual Machine • Android!s custom clean-room implementation 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 Android Runtime Core Libraries Dalvik Virtual Machine
  • 57. Dalvik Virtual Machine • Designed for embedded environment • Supports multiple virtual machine processes per device • Highly CPU-optimized bytecode interpreter • Uses runtime memory very efficiently Android Runtime Core Libraries Dalvik Virtual Machine
  • 58. Core Libraries • Core APIs for Java language provide a powerful, yet simple and familiar development platform • Data structures • Utilities • File access • Network Access • Graphics • … Android Runtime Core Libraries Dalvik Virtual Machine
  • 59. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Android Runtime • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 60. Android Anatomy Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager … Libraries Android Runtime Surface Manager Core Libraries Media Framework SQLite OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 61. Core Platform Services • Services that are essential to the Android platform • Behind the scenes - applications typically don!t access them directly Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 62. Core Platform Services • Activity Manager Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 63. Core Platform Services • Activity Manager • Package Manager Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 64. Core Platform Services • Activity Manager • Package Manager • Window Manager Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 65. Core Platform Services • Activity Manager • Package Manager • Window Manager • Resource Manager Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 66. Core Platform Services • Activity Manager • Package Manager • Window Manager • Resource Manager • Content Providers Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 67. Core Platform Services • Activity Manager • Package Manager • Window Manager • Resource Manager • Content Providers • View System Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 68. Hardware Services • Provide access to lower-level hardware APIs Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 69. Hardware Services • Provide access to lower-level hardware APIs • Typically accessed through local Manager object LocationManager lm = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE); Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 70. Hardware Services • Telephony Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 71. Hardware Services • Telephony Service • Location Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 72. Hardware Services • Telephony Service • Location Service • Bluetooth Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 73. Hardware Services • Telephony Service • Location Service • Bluetooth Service • WiFi Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 74. Hardware Services • Telephony Service • Location Service • Bluetooth Service • WiFi Service • USB Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 75. Hardware Services • Telephony Service • Location Service • Bluetooth Service • WiFi Service • USB Service • Sensor Service Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 76. Application Framework More Information • At Google I/O • “Inside the Android Application Framework” • Online • http://code.google.com/android Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager …
  • 77. Android Anatomy Applications Home Dialer SMS/MMS IM Browser Camera Alarm Calculator Contacts Voice Dial Email Calendar Media Player Albums Clock … Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager … Libraries Android Runtime Surface Manager Core Libraries Media Framework SQLite OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management
  • 78. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 79. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Application Framework • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 80. 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. Init Linux Kernel
  • 81. 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 usbd adbd debuggerd rild Init
  • 82. 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 usbd adbd debuggerd daemons Zygote Init
  • 83. 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 Service Manager usbd adbd debuggerd daemons runtime Zygote Init
  • 84. Runtime Walkthrough Runtime process sends request for Zygote to start System Service Service Manager usbd adbd debuggerd daemons runtime Zygote Init
  • 85. 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 Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 86. Runtime Walkthrough System Service starts the native system servers, including: • Surface Flinger • Audio Flinger Audio Flinger Surface Flinger Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 87. Runtime Walkthrough Native system servers register with Service Manager as IPC service targets: Audio Flinger Surface Flinger Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 88. Runtime Walkthrough System Service starts the Android managed services: Content Telephony Bluetooth Connectivity Location Manager Service Service Service Manager Window Activity Package Power Manager Manager Manager Manager … Camera Surface Service Flinger Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 89. Runtime Walkthrough Android managed Services register with Service Manager: Content Telephony Bluetooth Connectivity Location Manager Service Service Service Manager Window Activity Package Power Manager Manager Manager Manager … Service Camera Manager Service Camera Surface Service Flinger Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 90. Runtime Walkthrough … Power Manager Activity Manager Camera Surface Service Flinger Service System Manager Server usbd adbd debuggerd daemons runtime Zygote Dalvik VM Init
  • 91. Runtime Walkthrough After system server loads all services, the system is ready… Init Daemon runtime Zygote System Processes Server Activity Manager Package Manager Window Manager … Dalvik VM Surface Flinger usbd adbd Init debuggerd daemons runtime Zygote Audio Flinger
  • 92. Runtime Walkthrough After system server loads all services, the system is ready… Init Daemon runtime Zygote System Home Processes Server Home Activity Manager Dalvik VM Package Manager Window Manager … Dalvik VM Surface Flinger usbd adbd Init debuggerd daemons runtime Zygote Audio Flinger
  • 93. Runtime Walkthrough After system server loads all services, the system is ready… Init Daemon runtime Zygote System Home Processes Server Activity Home Manager Package Dalvik VM Manager Window Manager … Dalvik VM Surface Flinger usbd adbd Init debuggerd daemons runtime Zygote Audio Flinger libc libc libc libc libc libc
  • 94. Runtime Walkthrough Each subsequent application is launched in it!s own process Daemon runtime Zygote System Home Contacts Processes Server Activity Home Contacts Manager Package Dalvik VM Dalvik VM Manager Window Manager … Dalvik VM Surface Flinger usbd adbd debuggerd daemons runtime Zygote Audio Flinger libc libc libc libc libc libc
  • 95. Agenda • Android Anatomy • Linux Kernel • Native Libraries • Framework Services • Android Physiology • Start-up Walkthrough • Layer Interaction
  • 96. 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
  • 97. 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
  • 98. Android Runtime Services Applications Application Binder IPC Application Framework Runtime Service Libraries Linux Kernel Kernel Driver
  • 99. Android Runtime Services Applications Application Binder IPC Application Framework Runtime Service JNI Libraries Native Service Binding Linux Kernel Kernel Driver
  • 100. Android Runtime Services Applications Application Binder IPC Application Framework Runtime Service JNI Libraries Native Service Binding Dynamic load HAL Library Linux Kernel Kernel Driver
  • 101. Android Runtime Services Applications Application Binder IPC Application Framework Runtime Service JNI Libraries Native Service Binding Dynamic load HAL Library Linux Kernel Kernel Driver
  • 102. Example: Location Manager Applications Binder IPC Application Application Framework Location Manager Service GpsLocationProvider JNI Libraries GpsLocationProvider Dynamic load libgps.so Linux Kernel Kernel Driver
  • 103. 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
  • 104. Android Native Services Applications Application Application Framework Runtime Service JNI Libraries Native Service Binding Linux Kernel
  • 105. Android Native Services Applications Application Application Framework Runtime Service JNI Libraries Binder IPC Native Service Native Service Binding Linux Kernel
  • 106. Android Native Services Applications Application Application Framework Runtime Service JNI Libraries Binder IPC Native Service Native Service Binding Dynamic load HAL Library Linux Kernel
  • 107. Android Native Services Applications Application Application Framework Runtime Service JNI Libraries Binder IPC Native Service Native Service Binding Dynamic load HAL Library Linux Kernel Kernel Driver
  • 108. Android Native Services Applications Application Application Framework MediaPlayer JNI Libraries Binder IPC MediaPlayer AudioFlinger Dynamic load Media Framework libaudio.so Linux Kernel Kernel Driver
  • 109. Android Native Services Applications Application Application Framework MediaPlayer JNI Libraries Binder IPC MediaPlayer AudioFlinger Dynamic load Media libaudio.so Framework ALSA Linux Kernel Kernel Driver
  • 110. Android Native Services Applications Application Application Framework MediaPlayer JNI Libraries Binder IPC MediaPlayer AudioFlinger Dynamic load Media libaudio.so Framework Proprietary Audio Driver Linux Kernel
  • 111. 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
  • 112. Daemon Connection Applications Application Application Framework Runtime Service JNI Libraries Native Service Binding Linux Kernel Kernel Driver
  • 113. Daemon Connection Applications Application Application Framework Runtime Service JNI Libraries sockets Native Service Daemon Binding Linux Kernel Kernel Driver
  • 114. Daemon Connection Applications Application Application Framework Runtime Service JNI Libraries sockets Native Service Daemon Binding Dynamic load HAL Library Linux Kernel Kernel Driver
  • 115. Daemon Connection Applications Application Application Framework Telephony Manager JNI Libraries sockets Telephony rild Manager Dynamic load libril.so Linux Kernel Kernel Driver
  • 116. 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
  • 117. Android Anatomy Applications Home Dialer SMS/MMS IM Browser Camera Alarm Calculator Contacts Voice Dial Email Calendar Media Player Albums Clock … Application Framework Activity Manager Window View Notification Manager Content Providers System Manager Telephony Location Package Manager Manager Resource Manager Manager … Libraries Android Runtime Surface Manager Core Libraries Media Framework SQLite OpenGL|ES FreeType WebKit Dalvik Virtual Machine SGL SSL Libc Linux Kernel Display Driver Camera Driver Bluetooth Driver Shared Memory Binder (IPC) Driver Driver Audio Power USB Driver Keypad Driver WiFi Driver Drivers Management