Professional Documents
Culture Documents
Introduction To Android Window System: Chia-I Wu
Introduction To Android Window System: Chia-I Wu
Introduction To Android Window System: Chia-I Wu
Chia-I Wu olv@0xlab.org
Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A
Chia-I Wu olv@0xlab.org
Outline
Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A
Chia-I Wu olv@0xlab.org
System Architecture
Chia-I Wu olv@0xlab.org
System Architecture
Chia-I Wu olv@0xlab.org
System Architecture
Chia-I Wu olv@0xlab.org
Building Blocks
Chia-I Wu olv@0xlab.org
SurfaceManager
Chia-I Wu olv@0xlab.org
WindowManager
frameworks/base/services/java/ com/android/server/WindowManagerService.java About 9000 SLOC in one le. Poorly documented, bad namings, ... (Ask SurfaceManager to) create/layout surfaces on behalf of the clients Dispatch input events to clients Transition animation WindowManagerPolicy
Chia-I Wu olv@0xlab.org
ActivityManager
frameworks/base/services/java/ com/android/server/am/ Manage lifecycles of activities Manage stacking of activities Dispatch intents Spawn processes
Chia-I Wu olv@0xlab.org
Confusions
An activity has one or more windows (e.g. dialogs) A window has one or more surfaces (e.g. surface views) However, in window manager, a window is called a session A surface is called a window And an activity becomes roughly a token
Chia-I Wu olv@0xlab.org
Special Keys
Chia-I Wu olv@0xlab.org
Random Topics
Outline
Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A
Chia-I Wu olv@0xlab.org
Random Topics
Process View
SurfaceManager, WindowManager, and SurfaceManager are threads of a single process (system server) Every application is usually a process of itself
Chia-I Wu olv@0xlab.org
Random Topics
Zygote
Is a process started on system initialization Preloads java classes and resources Forks system server Listens silently on /dev/socket/zygote
Chia-I Wu olv@0xlab.org
Random Topics
Binder
Early in the lifetime of an application process, thread(s) are created and blocked on /dev/binder Binder is used mainly for RPC Fragile
Chia-I Wu olv@0xlab.org
Development Code
Outline
Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A
Chia-I Wu olv@0xlab.org
Development Code
Build System
Chia-I Wu olv@0xlab.org
Development Code
adb
ADBHOST for transport over TCP/IP kill-server remount pull/push logcat shell
Chia-I Wu olv@0xlab.org
Development Code
hierarchyviewer
Chia-I Wu olv@0xlab.org
Development Code
SurfaceFlinger has a SurfaceHeapManager Every client has a MemoryDealer, as returned by SurfaceHeapManager Every surface of a client also has dealer(s), from client or GPU
Chia-I Wu olv@0xlab.org
Development Code
A dealer consists of a heap and an allocator A heap represents a sharable big chunk of memory An allocator is an algorithm Small chunks of memory from the heap are returned
Chia-I Wu olv@0xlab.org
Development Code
Chia-I Wu olv@0xlab.org
Development Code
Real ow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked
Chia-I Wu olv@0xlab.org
Development Code
Real ow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuers is called to allocate buers
Chia-I Wu olv@0xlab.org
Development Code
Real ow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuers is called to allocate buers Two dealers are created from client, one for front buer and one for back buer
Chia-I Wu olv@0xlab.org
Development Code
Real ow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuers is called to allocate buers Two dealers are created from client, one for front buer and one for back buer Two LayerBitmaps are created, initialized with the two dealers
Chia-I Wu olv@0xlab.org
Development Code
Real ow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuers is called to allocate buers Two dealers are created from client, one for front buer and one for back buer Two LayerBitmaps are created, initialized with the two dealers Heaps of dealers along with info about the layer are returned
Chia-I Wu olv@0xlab.org
Development Code
Hello World
http://people.debian.org.tw/olv/surfaceinger/demo.tar.gz
Chia-I Wu olv@0xlab.org
Development Code
Many Buers
Surface is double buered EGLDisplaySurface is double buered Same technique; Dierent code pathes, dierent purposes
Chia-I Wu olv@0xlab.org
Development Code
Double Buering
Chia-I Wu olv@0xlab.org
Development Code
Dirty Region
Chia-I Wu olv@0xlab.org
Development Code
Frame 0
Chia-I Wu olv@0xlab.org
Development Code
Frame 1
Chia-I Wu olv@0xlab.org
Development Code
Frame 2
Chia-I Wu olv@0xlab.org
Outline
Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A
Chia-I Wu olv@0xlab.org
Q&A
Questions?
Chia-I Wu olv@0xlab.org