• No results found

Introduction to Android Window System

N/A
N/A
Protected

Academic year: 2021

Share "Introduction to Android Window System"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

Outline Building Blocks Under the Hood Get Dirty Q & A

Introduction to Android Window System

Chia-I Wu

[email protected]

(2)

Outline

Building Blocks Under the Hood Get Dirty Q & A

Building Blocks

Overview

Interested Components

Under the Hood

Random Topics

Get Dirty

Development Code

(3)

Outline

Building Blocks

Under the Hood Get Dirty Q & A Overview Interested Components

Outline

Building Blocks Overview Interested Components

Under the Hood

Random Topics

Get Dirty

Development Code

(4)

Outline

Building Blocks

Under the Hood Get Dirty Q & A

Overview

Interested Components

(5)

Outline

Building Blocks

Under the Hood Get Dirty Q & A

Overview

Interested Components

(6)

Outline

Building Blocks

Under the Hood Get Dirty Q & A

Overview

Interested Components

(7)

Outline

Building Blocks

Under the Hood Get Dirty Q & A

Overview

Interested Components

Building Blocks

There are more, but we focus on

I SurfaceManager

I WindowManager

(8)

Outline

Building Blocks

Under the Hood Get Dirty Q & A Overview Interested Components

SurfaceManager

I frameworks/base/libs/surfaceflinger/ I a.k.a SurfaceFlinger

I Allocate surfaces. Backed by ashmem/pmem/?

(9)

Outline

Building Blocks

Under the Hood Get Dirty Q & A Overview Interested Components

WindowManager

I frameworks/base/services/java/ com/android/server/WindowManagerService.java

I About 9000 SLOC in one file. Poorly documented, bad

namings, ...

I (Ask SurfaceManager to) create/layout surfaces on behalf of

the clients

I Dispatch input events to clients

I Transition animation

(10)

Outline

Building Blocks

Under the Hood Get Dirty Q & A Overview Interested Components

ActivityManager

I frameworks/base/services/java/ com/android/server/am/

I Manage lifecycles of activities

I Manage stacking of activities

I Dispatch intents

(11)

Outline

Building Blocks

Under the Hood Get Dirty Q & A

Overview

Interested Components

Confusions

I An activity has one or more windows (e.g. dialogs)

I A window has one or more surfaces (e.g. surface views)

I However, in window manager, a window is called a session

I A surface is called a window

(12)

Outline

Building Blocks

Under the Hood Get Dirty Q & A Overview Interested Components

Special Keys

I HOME key I BACK key

(13)

Outline Building Blocks

Under the Hood

Get Dirty Q & A Random Topics

Outline

Building Blocks Overview Interested Components

Under the Hood

Random Topics

Get Dirty

Development Code

(14)

Outline Building Blocks

Under the Hood

Get Dirty Q & A

Random Topics

Process View

I SurfaceManager, WindowManager, and SurfaceManager are

threads of a single process (system server)

(15)

Outline Building Blocks

Under the Hood

Get Dirty Q & A

Random Topics

Zygote

I Is a process started on system initialization

I Preloads java classes and resources

I Forks system server

(16)

Outline Building Blocks

Under the Hood

Get Dirty Q & A

Random Topics

Binder

I Early in the lifetime of an application process, thread(s) are

created and blocked on /dev/binder

I Binder is used mainly for RPC

(17)

Outline Building Blocks Under the Hood

Get Dirty Q & A Development Code

Outline

Building Blocks Overview Interested Components

Under the Hood

Random Topics

Get Dirty

Development Code

(18)

Outline Building Blocks Under the Hood

Get Dirty Q & A Development Code

Build System

I build/core/core/build-system.html I . build/envsetup.sh I showcommands

(19)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

adb

I ADBHOST for transport over TCP/IP

I kill-server

I remount

I pull/push

I logcat

(20)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

hierarchyviewer

I Display view hierarchy

I Display view

(21)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management

I SurfaceFlinger has a SurfaceHeapManager

I Every client has a MemoryDealer, as returned by

SurfaceHeapManager

(22)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

I A dealer consists of a heap and an allocator

I A heap represents a sharable big chunk of memory

I An allocator is an algorithm

(23)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(24)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(25)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(26)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(27)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(28)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Graphics: Memory Management cont.

Real flow

I A client asks for a new surface, createSurface

I createSurface calls createNormalSurfaceLocked

I A layer is created and setBuffers is called to allocate buffers

I Two dealers are created from client, one for front buffer and

one for back buffer

I Two LayerBitmaps are created, initialized with the two dealers

(29)

Outline Building Blocks Under the Hood

Get Dirty Q & A Development Code

Hello World

I http://people.debian.org.tw/˜olv/surfaceflinger/demo.tar.gz

(30)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Many Buffers

I Surface is double buffered

I EGLDisplaySurface is double buffered

(31)

Outline Building Blocks Under the Hood

Get Dirty Q & A Development Code

Double Buffering

I Sofware v.s. Hardware I Memory copy I Page flipping

(32)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

Dirty Region

I Associate buffers with dirty regions

(33)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

(34)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

(35)

Outline Building Blocks Under the Hood

Get Dirty

Q & A

Development

Code

(36)

Outline Building Blocks Under the Hood Get Dirty Q & A

Outline

Building Blocks Overview Interested Components

Under the Hood

Random Topics

Get Dirty

Development Code

(37)

Outline Building Blocks Under the Hood Get Dirty

Q & A

Q & A

References

Related documents