KEMBAR78
Introduction of Android Architecture | PPTX
1
Introduction of Android
Architecture
2
Agenda
• Introduction
• Android Architecture
3
• Open source attracts talent across the world.
• Apache license protects OEM’s business.
• Easy to use language and stable API improve
developer’s interest.
• Compatibility protects
Android’s Integrity.
• Rich Apps inspire
users’ interesting.
• GMS and data protect
Google’s interest.
Ecosystem
4
Architecture
5
Android Architecture
• Application
• SDK & NDK
• Framework & Runtime
• Hal
Application
SDK interface layer
Framework, Runtime and Libraries
Hal interface layer
HAL
Kernel
IPC
IPC
6
APK Structure
7
Four Components
8
Four Components
Activity
Content
Resolver
Broadcast
Reciever
Activity
Content
Resolver
Broadcast
Reciever
Service
Content
Resolver
Broadcast
Reciever
Activity
Content
Provider
Sqlite Data and XML
Application 1
Application 2
Application 3
Send broadcast
Bind or start
Service using IntentSend broadcast
to system
Filter intent by
intent filter
9
Activity Life Cycle
10
Android Architecture
• Application
• SDK & NDK
• Framework & Runtime
• Hal
Application
SDK interface layer
Framework, Runtime and Libraries
Hal interface layer
HAL
Kernel
IPC
IPC
11
SDK & NDK
• SDK API
 Android.*
 Dalvik.*
 Java.*
 Javax.*
• Soft API
 Permissions
 Build Parameters
 Intent
• NDK
libaaudio.so, libandroid.so, libz, JNI interface, libc,
libcamera2ndk.so, libdl, libEGL.so, libGLESv2.so, libGLESv3.so,
libicuuc.so, libjnigraphics.so, libm.so, libRS.so, libstdc++,
libvulkan.so …
SDK interface layer
Framework
Application
SDK interface layer
Application
IPC IPC
Client
Sever Function service Function service
12
Android Architecture
• Application
• SDK & NDK
• Framework & Runtime
• Hal
Application
SDK interface layer
Framework, Runtime and Libraries
Hal interface layer
HAL
Kernel
IPC
IPC
13
Framework – Type of Services
Service Type Example Process Function Crash
recovery
System Java
Services
AMS/PMS/UMS/W
MS/DMS/CMS/LMS
/…
SystemServer Provide critical
system services
Restart by
system
System Native
Services
MediaServer/Rild/A
udioflinger/surfacefli
nger/logd/adbd/deb
uggerd/..
Dedicated
process
Provide critical
system services
Restart by
system
APK Services KeyGuardServices Dedicated
process
Provide
application level
services
Restart by
app itself.
14
System Services Register and Query
Running in different
processes
ServiceManager
AMS UMS PMS WMS
DMS CMS LMS ...
adbd debuggerd rild logd
mediaserv
er
surfaceflin
ger
audiofling
er
Native service Daemons
Java system services
Client
Components
1 AddService(IPC)
2 getService(IPC)
3 Call the service
provied by UMS
Running in system
server process
15
APK1
Client
Components
2 Send Intent to
start or bind a
service
APK2
ServiceRecor
d List
PackageManager
Service
SystemServer
3 Call the service
provied by APK1
APK services Register and Query
APK will define some
filter to declare which
intent its services will
proceed.
1 PMS will parser all
APK when it is
installed or system
boot time to get
services information
APK will define some
filter to declare which
intent its services will
proceed.
PMS will be
responsible for start
APK1 if APK1 is not
started
16
Bionic
• Developed by Google
• BSD license
• Faster and smaller
• No compatibility with GUN libc
• Special function for Android, such as getprop
17
DALVIK vs ART
• Installation Time
• Storage Usage
• Performance
• Battery
18
Memory –Native Allocator
Application
System Runtime
System Kernel
Memory Allocator
Process Virtual Address Space Map Area Heap Area
malloc/calloc/realloc
Unit Unit
Unit Unit
brk/sbrkmmap/munmap
free
19
Hybrid JIT/AOT
20
From Java Method to Native Method
Function type
info is stored in
Dex/OAT file
21
Process and Thread
Java APK NDK APK
zygote Java process
Native
Daemon
Framework
App
Ā·
Thread
Ā·
Thread
Ā·
Ā·
Ā·
Fork
Process ProcessProcessProcess
Fork
Process
22
System Boot up
Will parser init.rc to
start all daemons
and zygote
Partitions will be
mounted and verified
one by one
Init process creates
daemons according
to some stages: init-
>boot->fs->data
23
Init
Fork
Start Linker
Load ELF and
depended lib
Zygote Process
Create
Heap
Init Art Vm in
libart.so
Create
Threads
Start Jit
Start GC Preload classes
Preload drawable
resource
Preload libraries
Enter loop to wait
for incoming
request
Fork request to
start system server
Split heap into two
heaps named
zygote and active
Start First Java Process - Zygote
Create one heap
named zygote using
Ashmem
First fork request will trigger
the heap split action to
improve GC performance
3000+ class and 400+
drawable will be loaded
in zygote so that they
can be shared across
all java processes
Create GC and other
threads
24
Android Architecture
• Application
• SDK & NDK
• Framework & Runtime
• Hal
Application
SDK interface layer
Framework, Runtime and Libraries
Hal interface layer
HAL
Kernel
IPC
IPC
25
HAL Treble Arch
26
HAL Treble Evolvement
27
Sensor
client
Vibrat
or c
Power
client
Init
ServiceManager
Zygote
System_server
vold
sufaceflinger
mediaserver
client
client
Sensor hal
process
HALServiceManag
er
Power hal process
audio hal process
IPC
IPC
IPC
HAL Treble Detailed Architecture
HalServiceManger will
be responsible for
maintaining all Hal
service
IPC is used to
communicate
from Hal Client
to Hal Service

Introduction of Android Architecture

  • 1.
  • 2.
  • 3.
    3 • Open sourceattracts talent across the world. • Apache license protects OEM’s business. • Easy to use language and stable API improve developer’s interest. • Compatibility protects Android’s Integrity. • Rich Apps inspire users’ interesting. • GMS and data protect Google’s interest. Ecosystem
  • 4.
  • 5.
    5 Android Architecture • Application •SDK & NDK • Framework & Runtime • Hal Application SDK interface layer Framework, Runtime and Libraries Hal interface layer HAL Kernel IPC IPC
  • 6.
  • 7.
  • 8.
    8 Four Components Activity Content Resolver Broadcast Reciever Activity Content Resolver Broadcast Reciever Service Content Resolver Broadcast Reciever Activity Content Provider Sqlite Dataand XML Application 1 Application 2 Application 3 Send broadcast Bind or start Service using IntentSend broadcast to system Filter intent by intent filter
  • 9.
  • 10.
    10 Android Architecture • Application •SDK & NDK • Framework & Runtime • Hal Application SDK interface layer Framework, Runtime and Libraries Hal interface layer HAL Kernel IPC IPC
  • 11.
    11 SDK & NDK •SDK API  Android.*  Dalvik.*  Java.*  Javax.* • Soft API  Permissions  Build Parameters  Intent • NDK libaaudio.so, libandroid.so, libz, JNI interface, libc, libcamera2ndk.so, libdl, libEGL.so, libGLESv2.so, libGLESv3.so, libicuuc.so, libjnigraphics.so, libm.so, libRS.so, libstdc++, libvulkan.so … SDK interface layer Framework Application SDK interface layer Application IPC IPC Client Sever Function service Function service
  • 12.
    12 Android Architecture • Application •SDK & NDK • Framework & Runtime • Hal Application SDK interface layer Framework, Runtime and Libraries Hal interface layer HAL Kernel IPC IPC
  • 13.
    13 Framework – Typeof Services Service Type Example Process Function Crash recovery System Java Services AMS/PMS/UMS/W MS/DMS/CMS/LMS /… SystemServer Provide critical system services Restart by system System Native Services MediaServer/Rild/A udioflinger/surfacefli nger/logd/adbd/deb uggerd/.. Dedicated process Provide critical system services Restart by system APK Services KeyGuardServices Dedicated process Provide application level services Restart by app itself.
  • 14.
    14 System Services Registerand Query Running in different processes ServiceManager AMS UMS PMS WMS DMS CMS LMS ... adbd debuggerd rild logd mediaserv er surfaceflin ger audiofling er Native service Daemons Java system services Client Components 1 AddService(IPC) 2 getService(IPC) 3 Call the service provied by UMS Running in system server process
  • 15.
    15 APK1 Client Components 2 Send Intentto start or bind a service APK2 ServiceRecor d List PackageManager Service SystemServer 3 Call the service provied by APK1 APK services Register and Query APK will define some filter to declare which intent its services will proceed. 1 PMS will parser all APK when it is installed or system boot time to get services information APK will define some filter to declare which intent its services will proceed. PMS will be responsible for start APK1 if APK1 is not started
  • 16.
    16 Bionic • Developed byGoogle • BSD license • Faster and smaller • No compatibility with GUN libc • Special function for Android, such as getprop
  • 17.
    17 DALVIK vs ART •Installation Time • Storage Usage • Performance • Battery
  • 18.
    18 Memory –Native Allocator Application SystemRuntime System Kernel Memory Allocator Process Virtual Address Space Map Area Heap Area malloc/calloc/realloc Unit Unit Unit Unit brk/sbrkmmap/munmap free
  • 19.
  • 20.
    20 From Java Methodto Native Method Function type info is stored in Dex/OAT file
  • 21.
    21 Process and Thread JavaAPK NDK APK zygote Java process Native Daemon Framework App Ā· Thread Ā· Thread Ā· Ā· Ā· Fork Process ProcessProcessProcess Fork Process
  • 22.
    22 System Boot up Willparser init.rc to start all daemons and zygote Partitions will be mounted and verified one by one Init process creates daemons according to some stages: init- >boot->fs->data
  • 23.
    23 Init Fork Start Linker Load ELFand depended lib Zygote Process Create Heap Init Art Vm in libart.so Create Threads Start Jit Start GC Preload classes Preload drawable resource Preload libraries Enter loop to wait for incoming request Fork request to start system server Split heap into two heaps named zygote and active Start First Java Process - Zygote Create one heap named zygote using Ashmem First fork request will trigger the heap split action to improve GC performance 3000+ class and 400+ drawable will be loaded in zygote so that they can be shared across all java processes Create GC and other threads
  • 24.
    24 Android Architecture • Application •SDK & NDK • Framework & Runtime • Hal Application SDK interface layer Framework, Runtime and Libraries Hal interface layer HAL Kernel IPC IPC
  • 25.
  • 26.
  • 27.
    27 Sensor client Vibrat or c Power client Init ServiceManager Zygote System_server vold sufaceflinger mediaserver client client Sensor hal process HALServiceManag er Powerhal process audio hal process IPC IPC IPC HAL Treble Detailed Architecture HalServiceManger will be responsible for maintaining all Hal service IPC is used to communicate from Hal Client to Hal Service

Editor's Notes

  • #5Ā Portability Easy Update Multiple products support Car IVI Android Auto Android TV Android wear Tablet Phone