There are many books, articles and paper publications about Android and related applications but only a few are related to how Android operating system works internally.In this talk we will see how android boots up , an overview of zygote , how system server and package manager works. This talk will be extremely helpful to foster understanding among android developers about Android Internals as well as everybody else who desires a general understanding of the internal working of Android powered devices.
3. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
4. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
5. Kernel
Special forked version of Linux
Features :
Wake locks
Low Memory Killer (OOM adjustment)
Provides Binder driver
6. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
7. INIT
Root / First User Space process
Responsibilities :
Set up file system permissions
Start native daemons
8. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
9. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
10. Zygote
Base of all other java processes
The app_process command invokes Android Runtime to start the first DVM/ART
The VM then invokes zygotes main method (ZygoteInit.java)
16. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
17. A Typical Android Boot-Up
KERNEL
Installd,
adbd,
servicemanger...
System Server
Zygote
App 1 , App 2 …App N
INIT
18. System Server
Heart of the Android System
Start system services
Register services with the service manager
19. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
20. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
21. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
22. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
23. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
24. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
25. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
26. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
27. System Server
Creates system context
Start bootstrap services
Start Other Services
Start core services
ActivityManagerService
PackageManagerService
WindowManagerService
Wifi/Bluetooth Service
SystemUI
Loads server library
28. Package Manager Service
Responsibilties :
Installation/Uninstallation of apps
Managing Permissions & Certificate Handling
Exposing APIs to 3rd party applications
29. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
30. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
31. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
32. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
33. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
34. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
35. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
36. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
37. Package Manager Service(Flow)
Scan Packages
Grant Permissions
Initialization
Manifest Parsing
Perform DexOpt
Collect Certificates
Generate Package Info
Asset Loading
38. Package Manager Service
Package information is cached into /data/system/packages.xml
Runtime permissions are cached into /data/system/0/runtime_packages.xml
40. PackageInstallerActivity
Launched when a new application is installed via side loading
Display parsing errors via a dialog.
Enable unknown applications setting.
Memory check
Check for same existing package
Install app
41. Installd
PMS lacks root privileges
Creating , deleting & changing the ownership of applications directories requires superuser capabilities .
The PMS delegates these operations to the installd daemon
42. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
43. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel
- Initialization
- Mount root FS
- Starts Init Process
Init
44. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel
Init
- Set up env variables
- Mount FS
- Set UP FS perm
- Start native daemons
45. A Quick Recap
Native Daemons
- servicemanager
- app_process -X Zygote
- adbd
- installd
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
46. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
- Start first VM
- Call zygote’s main method
Kernel Init
47. A Quick Recap
Native Daemons
Zygote
- Register Zygote socket
- Preload classes & res.
- Start systemserver process
- Listen for connections
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
48. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
- Start services
- Register with service manager
Activity Manager
Android Runtime
Kernel Init
49. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
- Init itself
- Send Intent.Category_HOME
- Send BOOT_COMPLETE
Android Runtime
Kernel Init
50. A Quick Recap
Native Daemons
Zygote
Launcher
- Init itself
- Register OnClick handlers
System Server
Activity Manager
Android Runtime
Kernel Init
51. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
Click
52. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
Click
53. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
Click
54. A Quick Recap
Native Daemons
Zygote
Launcher
System Server
Activity Manager
Android Runtime
Kernel Init
Click
55. A Quick Recap
Native Daemons
- servicemanager
- app_process -X Zygote
- adbd
- installd
Zygote
- Register Zygote socket
- Preload classes & resources
- Start systemserver process
- Listen for connections
Launcher
- Init itself
- Register OnClick handlers
Click
System Server
- Start services
- Register with servicemanager
Activity Manager
- Init itself
- Send Intent.Category_HOME
- Send BOOT_COMPLETE
broadcast
New app
Android Runtime
- Start first VM
- Call zygote’s main method
Kernel
- Initialization
- Mount root FS
- Starts Init Process
Init
- Set up env variables
- Mount FS
- Set UP FS perm
- Start native daemons