Sie sind auf Seite 1von 44

1

Inside Android's UI
Embedded Linux Conference Europe 2012
Karim Yaghmour
@arim!aghmour
karim.yaghmour@opersys.com
2
These slides are made available to you under a Creative Commons Share-
Alike 3. license. The !ull terms o! this license are here"
https"##creativecommons.org#licenses#by-sa#3.#
Attribution re$uirements and misc.% &'(AS( )(A*"

This slide must remain as-is in this speci!ic location +slide ,2-% everything
else you are !ree to change. including the logo "--

/se o! !igures in other documents must !eature the belo0 12riginals at3
/)' immediately under that !igure and the belo0 copyright notice 0here
appropriate.

4ou are !ree to !ill in the 1*elivered and#or customi5ed by3 space on the
right as you see !it.

4ou are 62)78*(9 !rom using the de!ault 1About3 slide as-is or any o! its
contents.

4ou are 62)78*(9 !rom using any content provided by 3


rd
parties 0ithout
the (:&'8C8T consent !rom those parties.
+C- Copyright 212% 2persys inc.
These slides created by" ;arim 4aghmour
2riginals at" 000.opersys.com#community#docs
*elivered and#or customi5ed by
3
About

Author o!"

8ntroduced 'inu< Trace Toolkit in 1===

2riginated Adeos and relay!s +kernel#relay.c-

Training% Custom *ev% Consulting% ...


>
Agenda

Android?s /8% 0hat?s that@

Architecture 7asics

*isplay Core

2penA'

8nput 'ayer

)elevant Apps and Services

System Startup

)e!erences and &ointers


B
1. Android?s /8% 0hat?s that@

"oC # $%U

&ouch inpu'

LC(

Ke!board
)))
C
1.1. Dhat 8?m 92T covering

Eedia layer

Stage6right

Fideo playback

Camera

*)E

(tc.
G
2. Architecture 7asics

Hard0are used to run Android

A2S&

7inder

System Services

HA'
I
=
1
11
12
13
#!rame0orks#base#services#Java#...
#!rame0orks#base#services#Jni#
#hard0are#libhard0are#
#device#KEA9/6.L#K*(F8C(L
#sdk#emulator#
;ernel or module
#!rame0orks#base#core#...
A2S&-provided
AS'
Eanu!.-provided
Eanu!. license
Eanu!.-provided
GPL-license
1>
3. *isplay Core

*isplay Hard0are

Classic 'inu< display stack

*isplay stack in Android

;ernel driver

HA' de!inition

HA' module

Sur!ace 6linger

Dindo0 Eanager

Dalkthrough
1B
3.1. *isplay Hard0are
EE/
82EE/
1C
3.2. Classic 'inu< display stack
1G
3.3. *isplay stack in Android
1I
1=
3.>. ;ernel driver

Fideo memory management

Eode setting

Checking o! parameters

Eotorola :oom"

#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#tegraMavp

#dev#tegraMcamera

#dev#tegraM!use

#dev#tegraMrpc

#dev#tegraMsema

... 0hatever hides in h0composer HA' module


2
3.B. HA' *e!inition

#hard0are#libhard0are#include#hard0are#h0composer.h

struct h0cMprocs"

invalidate+-

vsync+-

struct h0cMcomposerMdevice"

prepare+-

set+-

dump+-

register&rocs+-

$uery+-

N+-
21
3.C. HA' module

Skeleton #hard0are#libhard0are#modules#h0composer.cpp

#system#lib#h0#h0composer.72A)*.so

#system#lib#h0#gralloc.72A)*.so

(<. - Eot :oom"

h0composer.tegra.so

gralloc.tegra.so

Sur!ace 6linger hook"

#!rame0orks#native#services#sur!ace!linger#*isplayHard0are

HDComposer.cpp

&rovides !ake vsync i! none is provided in HD


22
3.G. Sur!ace 6linger

Actual server"

#!rame0orks#native#services#sur!ace!linger

Client side"

#!rame0orks#native#libs#gui

Client # Server inter!ace"

8Sur!aceComposerClient.cpp

8Sur!aceComposer.cpp

This is 92T an aidl?ed service

All communication is manually


marshalled#unmarshalled
23
3.I. Dindo0 Eanager

Server side"

#!rame0orks#base#services#Java#com#android#server#0m#

Dindo0EanagerService.Java

Session.Java

Client side"

#!rame0orks#base#core#Java#android#vie0#

Dindo0Eanager.Java

Dindo0Eanager8mpl.Java

Fie0)oot8mpl.Java

8nter!aces"

8Dindo0Eanager.aidl

8Dindo0Session.aidl

&arameters +incl. 5-order-"

See Dindo0Eanager.Java
2>
3.=. Dalkthrough

Activity Eanager relies on Activity Thread

AT calls on attach+- and makeFisible+-

makeFisible does 0m.addFie0+-

vm.addFie0+- - this also called by Status7ar to display itsel!

Creates a ne0 Fie0)oot8mpl

Call on its setFie0+-

setFie0+- calls on sDindo0Session.add+...-

This results in call to DE?s addDindo0+-

Fie0)oot8mpl?s per!ormTraversals+-

Calls on relayoutDindo0+-

Calls to DE session?s relayout+-

Call to DE?s relayoutDindo0+-

Call to createSur!ace'ocked+-

ne0 Sur!ace+...-
2B
>. 2penA'

Dhat?s 2penA'@

Dhat?s in a modern-day A&/@

So!t0are layers involved

;ernel driver

(A' libs

9ative inter!ace

Oava inter!ace

So!t0are A' implementation


2C
>.1. Dhat?s 2penA'@

8t?s Just an A&8 ... nothing but an A&8 ...

Check out Dikipedia

Eultiple versions out

1(S3 versions !or embedded use

/p to (S 3.

Android support up to (S 2.
2G
>.2. Dhat?s in a modern-day A&/@

A tremendous amount o! parallel processing units

1S8E*3-like instruction set

Fideo decoding#encoding capabilities

...
2I
>.3. So!t0are layers involved

;ernel driver

A' libraries

9ative A' A&8

Oava A' A&8


2=
>.>. ;ernel driver
P
R
O
P
R
I
E
T
A
R
Y
3
>.B. (A' libs

#!rame0orks#base#native#opengl#libs

(ntry point" #system#lib#lib(A'.so

'ooks !or #system#lib#egl#egl.c!g

#system#lib#egl - Eot :oom"

egl.c!g

lib(A'Mper!hud.so

lib(A'Mtegra.so

libA'(SMandroid.so

libA'(Sv1MCEMper!hud.so

libA'(Sv1MCEMtegra.so

libA'(Sv2Mper!hud.so

libA'(Sv2Mtegra.so

elg.c!g"
tegra
31
>.C. 9ative inter!ace

#!rame0orks#native#opengl#include

(A'

(TC1

A'(S

A'(S2

;H)
32
>.G. Oava inter!ace

A' libs re$uired by libandroidMruntime.so

#!rame0orks#base#opengl#Java#android#opengl"

...
33
>.I. So!t0are A' implementation

#!rame0orks#native#opengl#libagl
3>
B. 8nput 'ayer

;ernel side - 1std3 'inu< input layer"

#dev#input#N

9o HA' use

9ative lib"

libinput

#!rame0orks#base#services#input

8nput Eanager Service"

#!rame0orks#base#services#Java#com#android#server#input

Started and directly tied to Dindo0 Eanager

Speci!ic con!ig !iles +see source.android.com-

So!t keyboard"

#!rame0orks#base#core#Java#android#inputmethodservice

8nput methods"

#packages#inputmehods

http"##developer.android.com#guide#topics#te<t#creating-input-method.html
3B
C. )elevant Apps and Services

'auncher

Status7ar

Dallpaper Eanager Service

9oti!ication Service

App Didgets
3C
C.1. 'auncher

An app like any other

See #packages#app#'auncher2
3G
C.2. Status7ar

A uni$ue app

See #!rame0orks#base#packages#System/8

Connects to Status 7ar Eanager and gives an


inter!ace it can use to call back into Status 7ar

Can use set8con+- to display icons on the right

&rovides a C&/ usage add-on that renders


straight on rest o! display using higher 5-order
3I
C.3. Dallpaper Eanager Service

See
#!rame0orks#base#services#Java#com#android#se
rver#DallpaperEanagerService.Java
3=
C.>. 9oti!ication Service

Toasts

Status bar noti!ications

Aets handle to Status 7ar Service at


instantiation

/ses handle to communicate 0ith Status 7ar


>
C.B. App Didgets

See
#!rame0orks#base#services#Java#com#android#se
rver#AppDidgetService.Java
>1
G. System Startup

;ernel

8nit

7oot animation

'auncher
>2
G.1. 7oot animation

Started by Sur!ace 6linger

1bootanim3 binary

#!rame0orks#base#cmds#bootanimation

)elies on bootanimation.5ip 0# &9As +nothing but-

See
https"##github.com#CyanogenEod#androidMvendorMcm#tree#Jellybean#pre
built#common#bootanimatino

Eust contain a desc.t<t"


P0idthQ PheightQ P!psQ
p PcountQ PpauseQ PpathQ
p PcountQ PpauseQ PpathQ
>3
I. )e!erences and &ointers

1/se the source% 'uke3

Oim Huang?s 1Android Araphics3

7enJamin Rores? 1'inu< Eaga5ine # 6rance3 articles

E8&S article on graphics internals"

http"##developer.mips.com#212#>#11#learning-about-
android-graphics-subsystem#

StSphane Earchesin?s 1'inu< Araphics *rivers" an


8ntroduction3

http"##source.android.com#tech#input#inde<.html
>>
Thank you ...
karim.yaghmour@opersys.com

Das könnte Ihnen auch gefallen