Professional Documents
Culture Documents
Anatomy Physiology of An Android
Anatomy Physiology of An Android
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
Calendar
Media Player
Albums
Clock
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Runtime
Libraries
Surface Manager
Media Framework
SQLite
OpenGL|ES
FreeType
WebKit
SGL
SSL
Libc
Core Libraries
Dalvik Virtual Machine
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Agenda
Android Anatomy
Linux Kernel
Native Libraries
Android Runtime
Application Framework
Android Physiology
Start-up Walkthrough
Layer Interaction
Linux Kernel
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Linux Kernel
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Kernel Enhancements
Alarm
Ashmem
Binder
Power Management
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Binder: Problem
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Binder: Solution
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Binder in Action
Process A
Process B
App A
Service B
Binder in Action
Process A
App A
Process B
Context
Service B
Binder in Action
Process A
Process B
App A
Context
get service
Service B
Binder in Action
Process A
Process B
App A
Context
get service
service
Binder Driver
Service B
Binder in Action
Process A
Process B
App A
Context
get service
service
Binder Driver
Service B
Binder in Action
Process A
Process B
App A
Context
Binder Driver
get service
service
call foo(object)
Service B
Binder in Action
Process A
Process B
App A
Context
Binder Driver
get service
service
call foo(object)
marshal proxy
object
Service B
Binder in Action
Process A
Process B
App A
Context
Binder Driver
get service
service
call foo(object)
marshal proxy
object
relay to
IPC threads
Service B
Binder in Action
Process A
Process B
App A
Context
Binder Driver
get service
service
call foo(object)
marshal proxy
object
relay to
IPC threads
call return
Service B
Binder
http://code.google.com/android/reference/aidl.html
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
PM Problem
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
PM Solution
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Android PM in Action
App A
PowerManager
PM Driver
Android PM in Action
App A
PowerManager
new wake lock
PARTIAL
PM Driver
Android PM in Action
App A
PowerManager
new wake lock
PARTIAL
PM Driver
Android PM in Action
App A
PowerManager
PM Driver
Android PM in Action
App A
PowerManager
PM Driver
release
release
Android PM in Action
App A
PowerManager
PM Driver
release
release
Turn off
CPU
Android PM
android.os.PowerManager
userActivity(long when, );
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Kernel
The Android kernel source is available today
at:
http://git.android.com
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
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
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
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?
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
Why Bionic?
Why build a custom libc library?
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
system properties
log capabilities
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
Bionic libc
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
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
Media Framework
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
SQLite
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
Buffer
Surface Flinger
App
Surface
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
Surface Flinger
Libraries
Surface Manager
Media Framework
SQLite
WebKit
Libc
OpenGL|ES
Audio Manager
FreeType
SSL
Audio Flinger
Tone
Audio
App
App
Media
Player
Earpeace
Speaker
Audio Flinger
Bluetooth
Game Audio
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
Dialer
SMS/MMS
IM
Browser
Camera
Alarm
Calculator
Contacts
Voice Dial
Calendar
Media Player
Photo Album
Clock
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Runtime
Libraries
Surface
Manager
Media
Framework
SQLite
WebKit
Libc
Core Libraries
OpenGL|ES
Audio
Manager
FreeType
SSL
Audio
Camera
Bluetooth
GPS
Radio (RIL)
WiFi
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Audio
Camera
Bluetooth
GPS
Radio (RIL)
WiFi
Audio
Camera
Bluetooth
GPS
Radio (RIL)
WiFi
char
(*foo)( void );
(*bar)( void );
} AcmeFunctions;
Audio
Camera
Bluetooth
GPS
Radio (RIL)
WiFi
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
Android Runtime
Libraries
Surface Manager
Media Framework
SQLite
OpenGL|ES
FreeType
WebKit
SGL
SSL
Libc
Core Libraries
Dalvik Virtual Machine
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Android Runtime
Core Libraries
Dalvik Virtual Machine
Android Runtime
Core Libraries
Dalvik Virtual Machine
Core Libraries
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
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Runtime
Libraries
Surface Manager
Media Framework
SQLite
OpenGL|ES
FreeType
WebKit
SGL
SSL
Libc
Core Libraries
Dalvik Virtual Machine
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Package Manager
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Package Manager
Window Manager
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Package Manager
Window Manager
Resource Manager
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Package Manager
Window Manager
Resource Manager
Content Providers
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Activity Manager
Package Manager
Window Manager
Resource Manager
Content Providers
View System
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
LocationManager lm = (LocationManager)
Context.getSystemService(Context.LOCATION_SERVICE);
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Location Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Location Service
Bluetooth Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Location Service
Bluetooth Service
WiFi Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Location Service
Bluetooth Service
WiFi Service
USB Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Hardware Services
Telephony Service
Location Service
Bluetooth Service
WiFi Service
USB Service
Sensor Service
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Application Framework
More Information
At Google I/O
Online
http://code.google.com/android
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Anatomy
Applications
Home
Dialer
SMS/MMS
IM
Browser
Camera
Alarm
Calculator
Contacts
Voice Dial
Calendar
Media Player
Albums
Clock
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Runtime
Libraries
Surface Manager
Media Framework
SQLite
OpenGL|ES
FreeType
WebKit
SGL
SSL
Libc
Core Libraries
Dalvik Virtual Machine
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
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
Init
Linux Kernel
Runtime Walkthrough
Init starts Linux daemons, including:
usbd
adbd
debuggerd
Init
rild
Runtime Walkthrough
Init process starts the zygote process:
usbd
adbd
debuggerd
daemons
Zygote
Init
Runtime Walkthrough
Init starts runtime process:
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
Zygote
Runtime Walkthrough
Runtime process sends request for Zygote to start System
Service
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
Zygote
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
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
System Service starts the native system servers, including:
Surface Flinger
Audio Flinger
Audio Flinger
Surface
Flinger
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
Native system servers register with Service Manager as IPC
service targets:
Audio Flinger
Surface
Flinger
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
System Service starts the Android managed services:
Content
Manager
Window
Manager
Telephony
Service
Activity
Manager
Bluetooth
Service
Package
Manager
Connectivity
Service
Power
Manager
Location
Manager
Camera
Surface
Service
Flinger
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
Android managed Services register with Service Manager:
Content
Manager
Window
Manager
Telephony
Service
Activity
Manager
Bluetooth
Service
Package
Manager
Service
Camera
Manager
Service
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
Connectivity
Service
Power
Manager
Location
Manager
Camera
Surface
Service
Flinger
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
Power
Manager
Activity
Manager
Camera
Surface
Service
Flinger
Service
Manager
usbd
adbd
debuggerd
daemons
runtime
Init
System
Server
Zygote
Dalvik VM
Runtime Walkthrough
After system server loads all services, the system is ready
Init
Daemon
Processes
runtime
Zygote
System
Server
Activity
Manager
Package
Manager
Window
Manager
Dalvik VM
Init
usbd
adbd
debuggerd
daemons
runtime
Zygote
Surface
Flinger
Audio
Flinger
Runtime Walkthrough
After system server loads all services, the system is ready
Init
Daemon
Processes
runtime
Zygote
System
Server
Home
Home
Activity
Manager
Package
Manager
Window
Manager
Dalvik VM
Init
usbd
adbd
debuggerd
daemons
runtime
Zygote
Surface
Flinger
Audio
Flinger
Dalvik VM
Runtime Walkthrough
After system server loads all services, the system is ready
Init
Daemon
Processes
runtime
Zygote
System
Server
Home
Activity
Manager
Package
Manager
Window
Manager
Home
Dalvik VM
Dalvik VM
Init
usbd
adbd
debuggerd
daemons
runtime
Zygote
Surface
Flinger
Audio
Flinger
libc
libc
libc
libc
libc
libc
Runtime Walkthrough
Each subsequent application is launched in its own process
Daemon
Processes
runtime
Zygote
System
Server
Home
Contacts
Activity
Manager
Package
Manager
Window
Manager
Home
Contacts
Dalvik VM
Dalvik VM
libc
libc
Dalvik VM
usbd
adbd
debuggerd
daemons
runtime
Zygote
Surface
Flinger
Audio
Flinger
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
App
Runtime Service
Native Daemon
lib
lib
Layer Interaction
There are 3 main flavors of Android layer cake:
App
Runtime Service
lib
App
Runtime Service
Native Service
App
Runtime Service
Native Daemon
lib
lib
Application Framework
Runtime Service
Libraries
Linux Kernel
Kernel Driver
Application Framework
Runtime Service
JNI
Libraries
Native Service Binding
Linux Kernel
Kernel Driver
Application Framework
Runtime Service
JNI
Libraries
Native Service Binding
Dynamic load
HAL Library
Linux Kernel
Kernel Driver
Application Framework
Runtime Service
JNI
Libraries
Native Service Binding
Dynamic load
HAL Library
Linux Kernel
Kernel Driver
Binder IPC
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
App
Runtime Service
Native Daemon
lib
lib
Runtime
Service
JNI
Libraries
Linux Kernel
Native Service
Binding
Runtime
Service
JNI
Libraries
Linux Kernel
Native Service
Binding
Binder IPC
Native Service
Runtime
Service
JNI
Libraries
Native Service
Binding
Binder IPC
Native Service
Dynamic load
HAL Library
Linux Kernel
Runtime
Service
JNI
Libraries
Native Service
Binding
Binder IPC
Native Service
Dynamic load
HAL Library
Linux Kernel
Kernel Driver
MediaPlayer
JNI
Libraries
MediaPlayer
Binder IPC
AudioFlinger
Dynamic load
Media
Framework
libaudio.so
Linux Kernel
Kernel Driver
MediaPlayer
JNI
Libraries
MediaPlayer
Binder IPC
AudioFlinger
Dynamic load
Media
Framework
libaudio.so
ALSA
Linux Kernel
Kernel Driver
MediaPlayer
JNI
Libraries
MediaPlayer
Binder IPC
AudioFlinger
Dynamic load
Media
Framework
libaudio.so
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
App
Runtime Service
Native Daemon
lib
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
Native Service
Binding
sockets
Daemon
Linux Kernel
Kernel Driver
Daemon Connection
Applications
Application
Application
Framework
Runtime
Service
JNI
Libraries
Native Service
Binding
sockets
Daemon
Dynamic load
HAL Library
Linux Kernel
Kernel Driver
Daemon Connection
Applications
Application
Application
Framework
Telephony Manager
JNI
Libraries
Telephony
Manager
sockets
rild
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
App
Runtime Service
Native Daemon
lib
lib
Android Anatomy
Applications
Home
Dialer
SMS/MMS
IM
Browser
Camera
Alarm
Calculator
Contacts
Voice Dial
Calendar
Media Player
Albums
Clock
Application Framework
Activity Manager
Window
Manager
Content Providers
View
System
Notification
Manager
Package Manager
Telephony
Manager
Resource Manager
Location
Manager
Android Runtime
Libraries
Surface Manager
Media Framework
SQLite
OpenGL|ES
FreeType
WebKit
SGL
SSL
Libc
Core Libraries
Dalvik Virtual Machine
Linux Kernel
Display Driver
Camera Driver
Bluetooth Driver
Shared Memory
Driver
USB Driver
Keypad Driver
WiFi Driver
Audio
Drivers
Power
Management
The End
code.google.com
Questions
Q&A