SlideShare a Scribd company logo
1
Inside Android's UI
AnDevCon 2013
Karim Yaghmour
@karimyaghmour
karim.yaghmour@opersys.com
2
These slides are made available to you under a Creative Commons Share-
Alike 3.0 license. The full terms of this license are here:
https://creativecommons.org/licenses/by-sa/3.0/
Attribution requirements and misc., PLEASE READ:
â—Ź This slide must remain as-is in this specific location (slide #2), everything
else you are free to change; including the logo :-)
● Use of figures in other documents must feature the below “Originals at”
URL immediately under that figure and the below copyright notice where
appropriate.
● You are free to fill in the “Delivered and/or customized by” space on the
right as you see fit.
● You are FORBIDEN from using the default “About” slide as-is or any of its
contents.
â—Ź
You are FORBIDEN from using any content provided by 3rd
parties without
the EXPLICIT consent from those parties.
(C) Copyright 2013, Opersys inc.
These slides created by: Karim Yaghmour
Originals at: www.opersys.com/community/docs
Delivered and/or customized by
3
About
â—Ź Author of:
â—Ź Introduced Linux Trace Toolkit in 1999
â—Ź Originated Adeos and relayfs (kernel/relay.c)
â—Ź Training, Custom Dev, Consulting, ...
4
Agenda
â—Ź Android's UI, what's that?
â—Ź Architecture Basics
â—Ź Display Core
â—Ź OpenGL
â—Ź Input Layer
â—Ź Relevant Apps and Services
â—Ź System Startup
â—Ź References and Pointers
5
1. Android's UI, what's that?
â—ŹSoC / GPU
â—ŹTouch input
â—ŹLCD
â—ŹKeyboard
???
6
1.1. What I'm NOT covering
â—Ź Media layer
â—Ź StageFright
â—Ź Video playback
â—Ź Camera
â—Ź DRM
â—Ź Etc.
7
2. Architecture Basics
â—Ź Hardware used to run Android
â—Ź AOSP
â—Ź Binder
â—Ź System Services
â—Ź HAL
8
9
10
11
12
13
/frameworks/base/services/java/...
/frameworks/base/services/jni/
/hardware/libhardware/
/device/[MANUF.]/[DEVICE]
/sdk/emulator/
Kernel or module
/frameworks/base/core/...
AOSP-provided
ASL
Manuf.-provided
Manuf. license
Manuf.-provided
GPL-license
14
3. Display Core
â—Ź Display Hardware
â—Ź Classic Linux display stack
â—Ź Display stack in Android
â—Ź Kernel driver
â—Ź HAL definition
â—Ź HAL module
â—Ź Surface Flinger
â—Ź Window Manager
â—Ź Walkthrough
15
3.1. Display Hardware
MMU
IOMMU
16
3.2. Classic Linux display stack
17
3.3. Display stack in Android
18
19
3.4. Kernel driver
â—Ź
Video memory management
â—Ź
Mode setting
â—Ź Checking of parameters
â—Ź Motorola Xoom:
â—Ź
/dev/nvhdcp1
â—Ź /dev/nvhost-ctrl
â—Ź /dev/nvhost-display
â—Ź /dev/nvhost-dsi
â—Ź
/dev/nvhost-gr2d
â—Ź /dev/nvhost-gr3d
â—Ź
/dev/nvhost-isp
â—Ź
/dev/nvhost-mpe
â—Ź /dev/nvhost-vi
â—Ź /dev/nvmap
â—Ź /dev/tegra-crypto
â—Ź
/dev/tegra_avp
â—Ź
/dev/tegra_camera
â—Ź
/dev/tegra_fuse
â—Ź /dev/tegra_rpc
â—Ź /dev/tegra_sema
â—Ź ... whatever hides in hwcomposer HAL module
20
3.5. HAL Definition
â—Ź /hardware/libhardware/include/hardware/hwcomposer.h
â—Ź struct hwc_procs:
â—Ź invalidate()
â—Ź vsync()
â—Ź struct hwc_composer_device:
â—Ź prepare()
â—Ź set()
â—Ź dump()
â—Ź registerProcs()
â—Ź query()
â—Ź *()
21
3.6. HAL module
â—Ź Skeleton /hardware/libhardware/modules/hwcomposer.cpp
â—Ź /system/lib/hw/hwcomposer.BOARD.so
â—Ź /system/lib/hw/gralloc.BOARD.so
â—Ź Ex. - Mot Xoom:
â—Ź hwcomposer.tegra.so
â—Ź gralloc.tegra.so
â—Ź Surface Flinger hook:
â—Ź /frameworks/native/services/surfaceflinger/DisplayHardware
– HWComposer.cpp
– Provides fake vsync if none is provided in HW
22
3.7. Surface Flinger
â—Ź Actual server:
â—Ź /frameworks/native/services/surfaceflinger
â—Ź Client side:
â—Ź /frameworks/native/libs/gui
â—Ź Client / Server interface:
â—Ź ISurfaceComposerClient.cpp
â—Ź ISurfaceComposer.cpp
â—Ź This is NOT an aidl'ed service
â—Ź All communication is manually
marshalled/unmarshalled
23
3.8. Window Manager
â—Ź Server side:
â—Ź /frameworks/base/services/java/com/android/server/wm/
– WindowManagerService.java
– Session.java
â—Ź Client side:
â—Ź /frameworks/base/core/java/android/view/
– WindowManager.java
– WindowManagerImpl.java
– ViewRootImpl.java
â—Ź Interfaces:
â—Ź IWindowManager.aidl
â—Ź IWindowSession.aidl
â—Ź Parameters (incl. z-order):
â—Ź See WindowManager.java
24
3.9. Walkthrough
â—Ź Activity Manager relies on Activity Thread
â—Ź AT calls on attach() and makeVisible()
â—Ź makeVisible does wm.addView()
â—Ź wm.addView() - this also called by StatusBar to display itself
â—Ź Creates a new ViewRootImpl
â—Ź Call on its setView()
â—Ź setView() calls on mWindowSession.addToDisplay(...)
â—Ź This results in call to WM's addWindow()
â—Ź ViewRootImpl's performTraversals()
â—Ź Calls on relayoutWindow()
â—Ź Calls to WM session's relayout()
â—Ź Call to WM's relayoutWindow()
â—Ź Call to createSurfaceLocked()
â—Ź new Surface(...)
25
frameworks/base/core/java/android/*/*
LocalActivityManager.java: startActivity()
- moveToState()
- startActivityNow()
ActivityThread.java: startActivityNow()
- performLaunchActivity()
- attach() -- gets AM handle and ties to it
- handleResumeActivity()
- makeVisible()
Activity.java: makeVisible()
- wm.addView()
WindowManagerGlobal.java: addView()
- root = new ViewRootImpl()
- root.setView()
ViewRootImpl.java: setView()
- mWindowSession.addToDisplay()
IWindowSession.aidl: addToDisplay()
26
frameworks/base/services/java/com/android/server/wm/*
Session.java: addToDisplay()
- mService.addWindow()
WindowManagerService.java: addWindow()
...
frameworks/base/core/java/android/*/*
ViewRootImpl.java: performTraversals()
- relayoutWindow()
- mWindowSession.relayout()
frameworks/base/services/java/com/android/server/wm/*
Session.java: relayoutWindow()
- mService.relayoutWindow()
WindowManagerService.java: relayoutWindow()
- surface = winAnimator.createSurfaceLocked();
WindowStateAnimator.java: createSurfaceLocked()
- new Surface();
27
4. OpenGL
â—Ź What's OpenGL?
â—Ź What's in a modern-day GPU?
â—Ź Software layers involved
â—Ź Kernel driver
â—Ź EGL libs
â—Ź Native interface
â—Ź Java interface
â—Ź Software GL implementation
28
4.1. What's OpenGL?
â—Ź It's just an API ... nothing but an API ...
â—Ź Check out Wikipedia
â—Ź Multiple versions out
● “ES” versions for embedded use
â—Ź Up to ES 3.0
â—Ź Android support up to ES 2.0
29
4.2. What's in a modern-day GPU?
â—Ź A tremendous amount of parallel processing units
● “SIMD”-like instruction set
â—Ź Video decoding/encoding capabilities
â—Ź ...
30
4.3. Software layers involved
â—Ź Kernel driver
â—Ź GL libraries
â—Ź Native GL API
â—Ź Java GL API
31
4.4. Kernel driver
PROPRIETARY
32
4.5. EGL libs
â—Ź /frameworks/base/native/opengl/libs
â—Ź Entry point: /system/lib/libEGL.so
â—Ź
Looks for /system/lib/egl/egl.cfg
â—Ź /system/lib/egl - Mot Xoom:
â—Ź egl.cfg
â—Ź libEGL_perfhud.so
â—Ź libEGL_tegra.so
â—Ź libGLES_android.so
â—Ź libGLESv1_CM_perfhud.so
â—Ź libGLESv1_CM_tegra.so
â—Ź libGLESv2_perfhud.so
â—Ź libGLESv2_tegra.so
â—Ź
elg.cfg:
0 0 tegra
33
4.6. Native interface
â—Ź /frameworks/native/opengl/include
â—Ź EGL
â—Ź ETC1
â—Ź GLES
â—Ź GLES2
â—Ź KHR
34
4.7. Java interface
â—Ź GL libs required by libandroid_runtime.so
â—Ź /frameworks/base/opengl/java/android/opengl:
â—Ź ...
35
4.8. Software GL implementation
â—Ź /frameworks/native/opengl/libagl
36
5. Input Layer
● Kernel side - “std” Linux input layer:
â—Ź /dev/input/*
â—Ź No HAL use
â—Ź Native lib:
â—Ź libinput
â—Ź /frameworks/base/services/input
â—Ź Input Manager Service:
â—Ź /frameworks/base/services/java/com/android/server/input
â—Ź Started and directly tied to Window Manager
â—Ź Specific config files (see source.android.com)
â—Ź Soft keyboard:
â—Ź /frameworks/base/core/java/android/inputmethodservice
â—Ź Input methods:
â—Ź /packages/inputmehods
â—Ź http://developer.android.com/guide/topics/text/creating-input-method.html
37
6. Relevant Apps and Services
â—Ź Launcher
â—Ź StatusBar
â—Ź Wallpaper Manager Service
â—Ź Notification Service
â—Ź App Widgets
38
6.1. Launcher
â—Ź An app like any other
â—Ź See /packages/app/Launcher2
39
6.2. StatusBar
â—Ź A unique app
â—Ź See /frameworks/base/packages/SystemUI
â—Ź Connects to Status Bar Manager and gives an
interface it can use to call back into Status Bar
â—Ź Can use setIcon() to display icons on the right
â—Ź Provides a CPU usage add-on that renders
straight on rest of display using higher z-order
40
6.3. Wallpaper Manager Service
â—Ź See
/frameworks/base/services/java/com/android/se
rver/WallpaperManagerService.java
41
6.4. Notification Service
â—Ź Toasts
â—Ź Status bar notifications
â—Ź Gets handle to Status Bar Service at
instantiation
â—Ź Uses handle to communicate with Status Bar
42
6.5. App Widgets
â—Ź See
/frameworks/base/services/java/com/android/se
rver/AppWidgetService.java
43
7. System Startup
â—Ź Kernel
â—Ź Init
â—Ź Boot animation
â—Ź Launcher
44
7.1. Boot animation
â—Ź Started by Surface Flinger
● “bootanim” binary
â—Ź /frameworks/base/cmds/bootanimation
â—Ź Relies on bootanimation.zip w/ PNGs (nothing but)
â—Ź See
https://github.com/CyanogenMod/android_vendor_cm/tree/jellybean/pre
built/common/bootanimatino
â—Ź Must contain a desc.txt:
<width> <height> <fps>
p <count> <pause> <path>
p <count> <pause> <path>
45
8. References and Pointers
● “Use the source, Luke”
● Jim Huang's “Android Graphics”
● Benjamin Zores' “Linux Magazine / France” articles
â—Ź MIPS article on graphics internals:
http://developer.mips.com/2012/04/11/learning-about-
android-graphics-subsystem/
● Stéphane Marchesin's “Linux Graphics Drivers: an
Introduction”
http://source.android.com/tech/input/index.html
46
Thank you ...
karim.yaghmour@opersys.com

More Related Content

PDF
Android Security, From the Ground Up
Opersys inc.
 
PDF
Running Code in the Android Stack at ABS 2014
Opersys inc.
 
PDF
Customizing Android's UI
Opersys inc.
 
PDF
Scheduling in Android
Opersys inc.
 
PDF
Memory Management in Android
Opersys inc.
 
PDF
Memory Management in Android
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
PDF
Inside Android's UI at AnDevCon V
Opersys inc.
 
Android Security, From the Ground Up
Opersys inc.
 
Running Code in the Android Stack at ABS 2014
Opersys inc.
 
Customizing Android's UI
Opersys inc.
 
Scheduling in Android
Opersys inc.
 
Memory Management in Android
Opersys inc.
 
Memory Management in Android
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
Inside Android's UI at AnDevCon V
Opersys inc.
 

What's hot (20)

PDF
Scheduling in Android
Opersys inc.
 
PDF
Android Things Internals
Opersys inc.
 
PDF
Memory Management in Android
Opersys inc.
 
PDF
Android's Multimedia Framework
Opersys inc.
 
PDF
Customizing Android's UI
Opersys inc.
 
PDF
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 
PDF
Android Security Internals
Opersys inc.
 
PDF
Inside Android's UI / ABS 2013
Opersys inc.
 
PDF
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
PDF
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Headless Android at AnDevCon3
Opersys inc.
 
PDF
Android Platform Debugging and Development
Karim Yaghmour
 
PDF
Inside Android's UI
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Android Platform Debugging & Development
Qualcomm Developer Network
 
PDF
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
PDF
Android Internals
Opersys inc.
 
PDF
Android Jumpstart ESC SV 2012 Part I
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
Scheduling in Android
Opersys inc.
 
Android Things Internals
Opersys inc.
 
Memory Management in Android
Opersys inc.
 
Android's Multimedia Framework
Opersys inc.
 
Customizing Android's UI
Opersys inc.
 
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 
Android Security Internals
Opersys inc.
 
Inside Android's UI / ABS 2013
Opersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Headless Android at AnDevCon3
Opersys inc.
 
Android Platform Debugging and Development
Karim Yaghmour
 
Inside Android's UI
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging & Development
Qualcomm Developer Network
 
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
Android Internals
Opersys inc.
 
Android Jumpstart ESC SV 2012 Part I
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Ad

Viewers also liked (20)

PDF
Porting Android
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage at AnDevCon V
Opersys inc.
 
PDF
Customizing Android's UI
Opersys inc.
 
PDF
Cyborgstack
Opersys inc.
 
PDF
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage at Android Open 2011
Opersys inc.
 
PDF
Android Variants, Hacks, Tricks and Resources
Opersys inc.
 
PDF
Embedded Android Workshop
Opersys inc.
 
PDF
Android App Development Intro at ESC SV 2012
Opersys inc.
 
PDF
Embedded Android Workshop at AnDevCon VI
Opersys inc.
 
PDF
Embedded Android Workshop with Lollipop
Opersys inc.
 
PDF
Embedded Android Workshop
Opersys inc.
 
PDF
Embedded Android Workshop at ABS 2014
Opersys inc.
 
PDF
Memory Management in Android
Opersys inc.
 
PDF
Developing Android Platform Tools
Opersys inc.
 
PDF
Embedded Android Workshop at Embedded World Conference 2013
Opersys inc.
 
PDF
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
PDF
Android On Development Boards at AnDevCon3
Opersys inc.
 
PDF
Android Microconf at Linux Plumber 2012
Opersys inc.
 
PDF
Embedded Android Workshop
Opersys inc.
 
Porting Android
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon V
Opersys inc.
 
Customizing Android's UI
Opersys inc.
 
Cyborgstack
Opersys inc.
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Leveraging Android's Linux Heritage at Android Open 2011
Opersys inc.
 
Android Variants, Hacks, Tricks and Resources
Opersys inc.
 
Embedded Android Workshop
Opersys inc.
 
Android App Development Intro at ESC SV 2012
Opersys inc.
 
Embedded Android Workshop at AnDevCon VI
Opersys inc.
 
Embedded Android Workshop with Lollipop
Opersys inc.
 
Embedded Android Workshop
Opersys inc.
 
Embedded Android Workshop at ABS 2014
Opersys inc.
 
Memory Management in Android
Opersys inc.
 
Developing Android Platform Tools
Opersys inc.
 
Embedded Android Workshop at Embedded World Conference 2013
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Android On Development Boards at AnDevCon3
Opersys inc.
 
Android Microconf at Linux Plumber 2012
Opersys inc.
 
Embedded Android Workshop
Opersys inc.
 
Ad

Similar to Inside Android's UI at AnDevCon VI (20)

PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Inside Android's UI at AnDevCon IV
Opersys inc.
 
PDF
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Android Platform Debugging and Development
Opersys inc.
 
PDF
Android Platform Debugging and Development at ELCE 2013
Opersys inc.
 
PDF
Running Code in the Android Stack at ELCE 2013
Opersys inc.
 
PDF
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Embarcadero Technologies
 
PDF
Android's HIDL: Treble in the HAL
Opersys inc.
 
PDF
Android Attacks
Michael Scovetta
 
PDF
X Means Y
CommonsWare
 
PDF
Workshop su Android Kernel Hacking
Develer S.r.l.
 
ODP
Android crash debugging
Ashish Agrawal
 
PDF
Extending Android's Platform Toolsuite
Opersys inc.
 
PPTX
Android tools for testers
Maksim Kovalev
 
PDF
Android 3.0 Portland Java User Group 2011-03-15
sullis
 
ODP
Q4.11: Porting Android to new Platforms
Linaro
 
PDF
Android on Intel Architecture: ROM Cooking Tutorial
Ron Munitz
 
Android Platform Debugging and Development
Opersys inc.
 
Inside Android's UI at AnDevCon IV
Opersys inc.
 
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging and Development
Opersys inc.
 
Android Platform Debugging and Development at ELCE 2013
Opersys inc.
 
Running Code in the Android Stack at ELCE 2013
Opersys inc.
 
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Embarcadero Technologies
 
Android's HIDL: Treble in the HAL
Opersys inc.
 
Android Attacks
Michael Scovetta
 
X Means Y
CommonsWare
 
Workshop su Android Kernel Hacking
Develer S.r.l.
 
Android crash debugging
Ashish Agrawal
 
Extending Android's Platform Toolsuite
Opersys inc.
 
Android tools for testers
Maksim Kovalev
 
Android 3.0 Portland Java User Group 2011-03-15
sullis
 
Q4.11: Porting Android to new Platforms
Linaro
 
Android on Intel Architecture: ROM Cooking Tutorial
Ron Munitz
 

More from Opersys inc. (17)

PDF
Android Automotive
Opersys inc.
 
PDF
Android 10 Internals Update
Opersys inc.
 
PDF
Embedded Android Workshop with Pie
Opersys inc.
 
PDF
Android Treble: Blessing or Trouble?
Opersys inc.
 
PDF
Embedded Android Workshop with Oreo
Opersys inc.
 
PDF
Embedded Android Workshop with Nougat
Opersys inc.
 
PDF
Embedded Android Workshop with Nougat
Opersys inc.
 
PDF
Android Things: Android for IoT
Opersys inc.
 
PDF
Android Things Internals
Opersys inc.
 
PDF
Brillo / Weave Internals
Opersys inc.
 
PDF
Embedded Android Workshop with Nougat
Opersys inc.
 
PDF
Brillo / Weave Internals
Opersys inc.
 
PDF
Project Ara
Opersys inc.
 
PDF
Brillo/Weave Internals
Opersys inc.
 
PDF
Embedded Android Workshop with Marshmallow
Opersys inc.
 
PDF
Embedded Android Workshop with Marshmallow
Opersys inc.
 
PDF
Project Ara
Opersys inc.
 
Android Automotive
Opersys inc.
 
Android 10 Internals Update
Opersys inc.
 
Embedded Android Workshop with Pie
Opersys inc.
 
Android Treble: Blessing or Trouble?
Opersys inc.
 
Embedded Android Workshop with Oreo
Opersys inc.
 
Embedded Android Workshop with Nougat
Opersys inc.
 
Embedded Android Workshop with Nougat
Opersys inc.
 
Android Things: Android for IoT
Opersys inc.
 
Android Things Internals
Opersys inc.
 
Brillo / Weave Internals
Opersys inc.
 
Embedded Android Workshop with Nougat
Opersys inc.
 
Brillo / Weave Internals
Opersys inc.
 
Project Ara
Opersys inc.
 
Brillo/Weave Internals
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Project Ara
Opersys inc.
 

Recently uploaded (20)

PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Doc9.....................................
SofiaCollazos
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 

Inside Android's UI at AnDevCon VI

  • 1. 1 Inside Android's UI AnDevCon 2013 Karim Yaghmour @karimyaghmour [email protected]
  • 2. 2 These slides are made available to you under a Creative Commons Share- Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ Attribution requirements and misc., PLEASE READ: â—Ź This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) â—Ź Use of figures in other documents must feature the below “Originals at” URL immediately under that figure and the below copyright notice where appropriate. â—Ź You are free to fill in the “Delivered and/or customized by” space on the right as you see fit. â—Ź You are FORBIDEN from using the default “About” slide as-is or any of its contents. â—Ź You are FORBIDEN from using any content provided by 3rd parties without the EXPLICIT consent from those parties. (C) Copyright 2013, Opersys inc. These slides created by: Karim Yaghmour Originals at: www.opersys.com/community/docs Delivered and/or customized by
  • 3. 3 About â—Ź Author of: â—Ź Introduced Linux Trace Toolkit in 1999 â—Ź Originated Adeos and relayfs (kernel/relay.c) â—Ź Training, Custom Dev, Consulting, ...
  • 4. 4 Agenda â—Ź Android's UI, what's that? â—Ź Architecture Basics â—Ź Display Core â—Ź OpenGL â—Ź Input Layer â—Ź Relevant Apps and Services â—Ź System Startup â—Ź References and Pointers
  • 5. 5 1. Android's UI, what's that? â—ŹSoC / GPU â—ŹTouch input â—ŹLCD â—ŹKeyboard ???
  • 6. 6 1.1. What I'm NOT covering â—Ź Media layer â—Ź StageFright â—Ź Video playback â—Ź Camera â—Ź DRM â—Ź Etc.
  • 7. 7 2. Architecture Basics â—Ź Hardware used to run Android â—Ź AOSP â—Ź Binder â—Ź System Services â—Ź HAL
  • 8. 8
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 14. 14 3. Display Core â—Ź Display Hardware â—Ź Classic Linux display stack â—Ź Display stack in Android â—Ź Kernel driver â—Ź HAL definition â—Ź HAL module â—Ź Surface Flinger â—Ź Window Manager â—Ź Walkthrough
  • 16. 16 3.2. Classic Linux display stack
  • 17. 17 3.3. Display stack in Android
  • 18. 18
  • 19. 19 3.4. Kernel driver â—Ź Video memory management â—Ź Mode setting â—Ź Checking of parameters â—Ź Motorola Xoom: â—Ź /dev/nvhdcp1 â—Ź /dev/nvhost-ctrl â—Ź /dev/nvhost-display â—Ź /dev/nvhost-dsi â—Ź /dev/nvhost-gr2d â—Ź /dev/nvhost-gr3d â—Ź /dev/nvhost-isp â—Ź /dev/nvhost-mpe â—Ź /dev/nvhost-vi â—Ź /dev/nvmap â—Ź /dev/tegra-crypto â—Ź /dev/tegra_avp â—Ź /dev/tegra_camera â—Ź /dev/tegra_fuse â—Ź /dev/tegra_rpc â—Ź /dev/tegra_sema â—Ź ... whatever hides in hwcomposer HAL module
  • 20. 20 3.5. HAL Definition â—Ź /hardware/libhardware/include/hardware/hwcomposer.h â—Ź struct hwc_procs: â—Ź invalidate() â—Ź vsync() â—Ź struct hwc_composer_device: â—Ź prepare() â—Ź set() â—Ź dump() â—Ź registerProcs() â—Ź query() â—Ź *()
  • 21. 21 3.6. HAL module â—Ź Skeleton /hardware/libhardware/modules/hwcomposer.cpp â—Ź /system/lib/hw/hwcomposer.BOARD.so â—Ź /system/lib/hw/gralloc.BOARD.so â—Ź Ex. - Mot Xoom: â—Ź hwcomposer.tegra.so â—Ź gralloc.tegra.so â—Ź Surface Flinger hook: â—Ź /frameworks/native/services/surfaceflinger/DisplayHardware – HWComposer.cpp – Provides fake vsync if none is provided in HW
  • 22. 22 3.7. Surface Flinger â—Ź Actual server: â—Ź /frameworks/native/services/surfaceflinger â—Ź Client side: â—Ź /frameworks/native/libs/gui â—Ź Client / Server interface: â—Ź ISurfaceComposerClient.cpp â—Ź ISurfaceComposer.cpp â—Ź This is NOT an aidl'ed service â—Ź All communication is manually marshalled/unmarshalled
  • 23. 23 3.8. Window Manager â—Ź Server side: â—Ź /frameworks/base/services/java/com/android/server/wm/ – WindowManagerService.java – Session.java â—Ź Client side: â—Ź /frameworks/base/core/java/android/view/ – WindowManager.java – WindowManagerImpl.java – ViewRootImpl.java â—Ź Interfaces: â—Ź IWindowManager.aidl â—Ź IWindowSession.aidl â—Ź Parameters (incl. z-order): â—Ź See WindowManager.java
  • 24. 24 3.9. Walkthrough â—Ź Activity Manager relies on Activity Thread â—Ź AT calls on attach() and makeVisible() â—Ź makeVisible does wm.addView() â—Ź wm.addView() - this also called by StatusBar to display itself â—Ź Creates a new ViewRootImpl â—Ź Call on its setView() â—Ź setView() calls on mWindowSession.addToDisplay(...) â—Ź This results in call to WM's addWindow() â—Ź ViewRootImpl's performTraversals() â—Ź Calls on relayoutWindow() â—Ź Calls to WM session's relayout() â—Ź Call to WM's relayoutWindow() â—Ź Call to createSurfaceLocked() â—Ź new Surface(...)
  • 25. 25 frameworks/base/core/java/android/*/* LocalActivityManager.java: startActivity() - moveToState() - startActivityNow() ActivityThread.java: startActivityNow() - performLaunchActivity() - attach() -- gets AM handle and ties to it - handleResumeActivity() - makeVisible() Activity.java: makeVisible() - wm.addView() WindowManagerGlobal.java: addView() - root = new ViewRootImpl() - root.setView() ViewRootImpl.java: setView() - mWindowSession.addToDisplay() IWindowSession.aidl: addToDisplay()
  • 26. 26 frameworks/base/services/java/com/android/server/wm/* Session.java: addToDisplay() - mService.addWindow() WindowManagerService.java: addWindow() ... frameworks/base/core/java/android/*/* ViewRootImpl.java: performTraversals() - relayoutWindow() - mWindowSession.relayout() frameworks/base/services/java/com/android/server/wm/* Session.java: relayoutWindow() - mService.relayoutWindow() WindowManagerService.java: relayoutWindow() - surface = winAnimator.createSurfaceLocked(); WindowStateAnimator.java: createSurfaceLocked() - new Surface();
  • 27. 27 4. OpenGL â—Ź What's OpenGL? â—Ź What's in a modern-day GPU? â—Ź Software layers involved â—Ź Kernel driver â—Ź EGL libs â—Ź Native interface â—Ź Java interface â—Ź Software GL implementation
  • 28. 28 4.1. What's OpenGL? â—Ź It's just an API ... nothing but an API ... â—Ź Check out Wikipedia â—Ź Multiple versions out â—Ź “ES” versions for embedded use â—Ź Up to ES 3.0 â—Ź Android support up to ES 2.0
  • 29. 29 4.2. What's in a modern-day GPU? â—Ź A tremendous amount of parallel processing units â—Ź “SIMD”-like instruction set â—Ź Video decoding/encoding capabilities â—Ź ...
  • 30. 30 4.3. Software layers involved â—Ź Kernel driver â—Ź GL libraries â—Ź Native GL API â—Ź Java GL API
  • 32. 32 4.5. EGL libs â—Ź /frameworks/base/native/opengl/libs â—Ź Entry point: /system/lib/libEGL.so â—Ź Looks for /system/lib/egl/egl.cfg â—Ź /system/lib/egl - Mot Xoom: â—Ź egl.cfg â—Ź libEGL_perfhud.so â—Ź libEGL_tegra.so â—Ź libGLES_android.so â—Ź libGLESv1_CM_perfhud.so â—Ź libGLESv1_CM_tegra.so â—Ź libGLESv2_perfhud.so â—Ź libGLESv2_tegra.so â—Ź elg.cfg: 0 0 tegra
  • 33. 33 4.6. Native interface â—Ź /frameworks/native/opengl/include â—Ź EGL â—Ź ETC1 â—Ź GLES â—Ź GLES2 â—Ź KHR
  • 34. 34 4.7. Java interface â—Ź GL libs required by libandroid_runtime.so â—Ź /frameworks/base/opengl/java/android/opengl: â—Ź ...
  • 35. 35 4.8. Software GL implementation â—Ź /frameworks/native/opengl/libagl
  • 36. 36 5. Input Layer â—Ź Kernel side - “std” Linux input layer: â—Ź /dev/input/* â—Ź No HAL use â—Ź Native lib: â—Ź libinput â—Ź /frameworks/base/services/input â—Ź Input Manager Service: â—Ź /frameworks/base/services/java/com/android/server/input â—Ź Started and directly tied to Window Manager â—Ź Specific config files (see source.android.com) â—Ź Soft keyboard: â—Ź /frameworks/base/core/java/android/inputmethodservice â—Ź Input methods: â—Ź /packages/inputmehods â—Ź http://developer.android.com/guide/topics/text/creating-input-method.html
  • 37. 37 6. Relevant Apps and Services â—Ź Launcher â—Ź StatusBar â—Ź Wallpaper Manager Service â—Ź Notification Service â—Ź App Widgets
  • 38. 38 6.1. Launcher â—Ź An app like any other â—Ź See /packages/app/Launcher2
  • 39. 39 6.2. StatusBar â—Ź A unique app â—Ź See /frameworks/base/packages/SystemUI â—Ź Connects to Status Bar Manager and gives an interface it can use to call back into Status Bar â—Ź Can use setIcon() to display icons on the right â—Ź Provides a CPU usage add-on that renders straight on rest of display using higher z-order
  • 40. 40 6.3. Wallpaper Manager Service â—Ź See /frameworks/base/services/java/com/android/se rver/WallpaperManagerService.java
  • 41. 41 6.4. Notification Service â—Ź Toasts â—Ź Status bar notifications â—Ź Gets handle to Status Bar Service at instantiation â—Ź Uses handle to communicate with Status Bar
  • 42. 42 6.5. App Widgets â—Ź See /frameworks/base/services/java/com/android/se rver/AppWidgetService.java
  • 43. 43 7. System Startup â—Ź Kernel â—Ź Init â—Ź Boot animation â—Ź Launcher
  • 44. 44 7.1. Boot animation â—Ź Started by Surface Flinger â—Ź “bootanim” binary â—Ź /frameworks/base/cmds/bootanimation â—Ź Relies on bootanimation.zip w/ PNGs (nothing but) â—Ź See https://github.com/CyanogenMod/android_vendor_cm/tree/jellybean/pre built/common/bootanimatino â—Ź Must contain a desc.txt: <width> <height> <fps> p <count> <pause> <path> p <count> <pause> <path>
  • 45. 45 8. References and Pointers â—Ź “Use the source, Luke” â—Ź Jim Huang's “Android Graphics” â—Ź Benjamin Zores' “Linux Magazine / France” articles â—Ź MIPS article on graphics internals: http://developer.mips.com/2012/04/11/learning-about- android-graphics-subsystem/ â—Ź StĂ©phane Marchesin's “Linux Graphics Drivers: an Introduction” http://source.android.com/tech/input/index.html