SlideShare a Scribd company logo
1 of 37
Download to read offline
Outline
               Building Blocks
              Under the Hood
                     Get Dirty
                        Q&A




Introduction to Android Window System

                     Chia-I Wu
                   olv@0xlab.org



                     May 15, 2009




      Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                       Building Blocks
                      Under the Hood
                             Get Dirty
                                Q&A




Building Blocks
   Overview
   Interested Components

Under the Hood
   Random Topics

Get Dirty
   Development
   Code

Q&A



              Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Overview
                         Under the Hood
                                            Interested Components
                                Get Dirty
                                   Q&A


Outline

   Building Blocks
      Overview
      Interested Components

   Under the Hood
      Random Topics

   Get Dirty
      Development
      Code

   Q&A


                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                       Building Blocks
                                         Overview
                      Under the Hood
                                         Interested Components
                             Get Dirty
                                Q&A


System Architecture




              Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                       Building Blocks
                                         Overview
                      Under the Hood
                                         Interested Components
                             Get Dirty
                                Q&A


System Architecture




              Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                       Building Blocks
                                         Overview
                      Under the Hood
                                         Interested Components
                             Get Dirty
                                Q&A


System Architecture




              Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                           Building Blocks
                                             Overview
                          Under the Hood
                                             Interested Components
                                 Get Dirty
                                    Q&A


Building Blocks



   There are more, but we focus on
       SurfaceManager
       WindowManager
       ActivityManager




                  Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Overview
                         Under the Hood
                                            Interested Components
                                Get Dirty
                                   Q&A


SurfaceManager




      frameworks/base/libs/surfaceflinger/
      a.k.a SurfaceFlinger
      Allocate surfaces. Backed by ashmem/pmem/?
      Composite surfaces




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                         Building Blocks
                                           Overview
                        Under the Hood
                                           Interested Components
                               Get Dirty
                                  Q&A


WindowManager


     frameworks/base/services/java/
     com/android/server/WindowManagerService.java
     About 9000 SLOC in one file. 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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Overview
                         Under the Hood
                                            Interested Components
                                Get Dirty
                                   Q&A


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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Overview
                         Under the Hood
                                            Interested Components
                                Get Dirty
                                   Q&A


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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Overview
                         Under the Hood
                                            Interested Components
                                Get Dirty
                                   Q&A


Special Keys




      HOME key
      BACK key




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                         Under the Hood     Random Topics
                                Get Dirty
                                   Q&A


Outline

   Building Blocks
      Overview
      Interested Components

   Under the Hood
      Random Topics

   Get Dirty
      Development
      Code

   Q&A


                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                         Under the Hood     Random Topics
                                Get Dirty
                                   Q&A


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    Introduction to Android Window System
Outline
                             Building Blocks
                            Under the Hood     Random Topics
                                   Get Dirty
                                      Q&A


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    Introduction to Android Window System
Outline
                             Building Blocks
                            Under the Hood     Random Topics
                                   Get Dirty
                                      Q&A


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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Outline

   Building Blocks
      Overview
      Interested Components

   Under the Hood
      Random Topics

   Get Dirty
      Development
      Code

   Q&A


                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                         Building Blocks
                                           Development
                        Under the Hood
                                           Code
                               Get Dirty
                                  Q&A


Build System




      build/core/core/build-system.html
      .   build/envsetup.sh
      showcommands
      export ANDROID JAVA HOME if non-standard




                Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                             Building Blocks
                                               Development
                            Under the Hood
                                               Code
                                   Get Dirty
                                      Q&A


adb



      ADBHOST for transport over TCP/IP
      kill-server
      remount
      pull/push
      logcat
      shell




                    Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                           Building Blocks
                                             Development
                          Under the Hood
                                             Code
                                 Get Dirty
                                    Q&A


hierarchyviewer




       Display view hierarchy
       Display view
       Invalidate/Relayout




                  Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                         Building Blocks
                                           Development
                        Under the Hood
                                           Code
                               Get Dirty
                                  Q&A


Graphics: Memory Management




     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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.




      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    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface
      createSurface calls createNormalSurfaceLocked




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface
      createSurface calls createNormalSurfaceLocked
      A layer is created and setBuffers is called to allocate buffers




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface
      createSurface calls createNormalSurfaceLocked
      A layer is created and setBuffers is called to allocate buffers
      Two dealers are created from client, one for front buffer and
      one for back buffer




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface
      createSurface calls createNormalSurfaceLocked
      A layer is created and setBuffers is called to allocate buffers
      Two dealers are created from client, one for front buffer and
      one for back buffer
      Two LayerBitmaps are created, initialized with the two dealers




                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                          Building Blocks
                                            Development
                         Under the Hood
                                            Code
                                Get Dirty
                                   Q&A


Graphics: Memory Management cont.


  Real flow
      A client asks for a new surface, createSurface
      createSurface calls createNormalSurfaceLocked
      A layer is created and setBuffers is called to allocate buffers
      Two dealers are created from client, one for front buffer and
      one for back buffer
      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    Introduction to Android Window System
Outline
                         Building Blocks
                                           Development
                        Under the Hood
                                           Code
                               Get Dirty
                                  Q&A


Hello World




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




                Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                        Building Blocks
                                          Development
                       Under the Hood
                                          Code
                              Get Dirty
                                 Q&A


Many Buffers




     Surface is double buffered
     EGLDisplaySurface is double buffered
     Same technique; Different code pathes, different purposes




               Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                         Building Blocks
                                           Development
                        Under the Hood
                                           Code
                               Get Dirty
                                  Q&A


Double Buffering




      Sofware v.s. Hardware
      Memory copy
      Page flipping




                Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                           Building Blocks
                                             Development
                          Under the Hood
                                             Code
                                 Get Dirty
                                    Q&A


Dirty Region




      Associate buffers with dirty regions
      Copy back




                  Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                   Building Blocks
                                     Development
                  Under the Hood
                                     Code
                         Get Dirty
                            Q&A


Frame 0




          Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                   Building Blocks
                                     Development
                  Under the Hood
                                     Code
                         Get Dirty
                            Q&A


Frame 1




          Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                   Building Blocks
                                     Development
                  Under the Hood
                                     Code
                         Get Dirty
                            Q&A


Frame 2




          Chia-I Wu olv@0xlab.org    Introduction to Android Window System
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

   Q&A


                 Chia-I Wu olv@0xlab.org    Introduction to Android Window System
Outline
                            Building Blocks
                           Under the Hood
                                  Get Dirty
                                     Q&A


Q&A




      Questions?




                   Chia-I Wu olv@0xlab.org    Introduction to Android Window System

More Related Content

What's hot

Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 

What's hot (20)

Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 

Similar to Introduction to Android Window System

Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
ThoughtWorks Studios
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
Thoughtworks
 
DefCon 2012 - Finding Firmware Vulnerabilities
DefCon 2012 - Finding Firmware VulnerabilitiesDefCon 2012 - Finding Firmware Vulnerabilities
DefCon 2012 - Finding Firmware Vulnerabilities
Michael Smith
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
Imam Raza
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
Thoughtworks
 

Similar to Introduction to Android Window System (20)

Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience
 
Build to Hack, Hack to Build
Build to Hack, Hack to BuildBuild to Hack, Hack to Build
Build to Hack, Hack to Build
 
Architecting modern Android apps
Architecting modern Android appsArchitecting modern Android apps
Architecting modern Android apps
 
What is web2.0
What is web2.0What is web2.0
What is web2.0
 
[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?[Wroclaw #7] Why So Serial?
[Wroclaw #7] Why So Serial?
 
Java course-in-mumbai
Java course-in-mumbaiJava course-in-mumbai
Java course-in-mumbai
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
DefCon 2012 - Finding Firmware Vulnerabilities
DefCon 2012 - Finding Firmware VulnerabilitiesDefCon 2012 - Finding Firmware Vulnerabilities
DefCon 2012 - Finding Firmware Vulnerabilities
 
DefCon 2012 - Firmware Vulnerability Hunting with FRAK
DefCon 2012 - Firmware Vulnerability Hunting with FRAKDefCon 2012 - Firmware Vulnerability Hunting with FRAK
DefCon 2012 - Firmware Vulnerability Hunting with FRAK
 
Mocking vtcc3 - en
Mocking   vtcc3 - enMocking   vtcc3 - en
Mocking vtcc3 - en
 
2.1. Dissecting blackberry
2.1. Dissecting blackberry2.1. Dissecting blackberry
2.1. Dissecting blackberry
 
OWASP AppSec Cali 2018 - Enabling Product Security With Culture and Cloud (As...
OWASP AppSec Cali 2018 - Enabling Product Security With Culture and Cloud (As...OWASP AppSec Cali 2018 - Enabling Product Security With Culture and Cloud (As...
OWASP AppSec Cali 2018 - Enabling Product Security With Culture and Cloud (As...
 
Dip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentationDip(dependency inversion principle) presentation
Dip(dependency inversion principle) presentation
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
Bhavin_Resume
Bhavin_ResumeBhavin_Resume
Bhavin_Resume
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
2015 06-wso2 coneu-closingkeynote-asanka
2015 06-wso2 coneu-closingkeynote-asanka2015 06-wso2 coneu-closingkeynote-asanka
2015 06-wso2 coneu-closingkeynote-asanka
 
Cloud Security & Compliance - JPMC Overview
Cloud Security & Compliance - JPMC OverviewCloud Security & Compliance - JPMC Overview
Cloud Security & Compliance - JPMC Overview
 
Cloud Security & Compliance - JPMC Overview
Cloud Security & Compliance - JPMC OverviewCloud Security & Compliance - JPMC Overview
Cloud Security & Compliance - JPMC Overview
 

More from National Cheng Kung University

More from National Cheng Kung University (20)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVMImplement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
 
Priority Inversion on Mars
Priority Inversion on MarsPriority Inversion on Mars
Priority Inversion on Mars
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Introduction to Android Window System

  • 1. Outline Building Blocks Under the Hood Get Dirty Q&A Introduction to Android Window System Chia-I Wu olv@0xlab.org May 15, 2009 Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 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 Q&A Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 3. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A Outline Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 4. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A System Architecture Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 5. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A System Architecture Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 6. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A System Architecture Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 7. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A Building Blocks There are more, but we focus on SurfaceManager WindowManager ActivityManager Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 8. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A SurfaceManager frameworks/base/libs/surfaceflinger/ a.k.a SurfaceFlinger Allocate surfaces. Backed by ashmem/pmem/? Composite surfaces Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 9. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A WindowManager frameworks/base/services/java/ com/android/server/WindowManagerService.java About 9000 SLOC in one file. 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 Introduction to Android Window System
  • 10. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A 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 Introduction to Android Window System
  • 11. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A 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 Introduction to Android Window System
  • 12. Outline Building Blocks Overview Under the Hood Interested Components Get Dirty Q&A Special Keys HOME key BACK key Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 13. Outline Building Blocks Under the Hood Random Topics Get Dirty Q&A Outline Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 14. Outline Building Blocks Under the Hood Random Topics Get Dirty Q&A 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 Introduction to Android Window System
  • 15. Outline Building Blocks Under the Hood Random Topics Get Dirty Q&A 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 Introduction to Android Window System
  • 16. Outline Building Blocks Under the Hood Random Topics Get Dirty Q&A 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 Introduction to Android Window System
  • 17. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Outline Building Blocks Overview Interested Components Under the Hood Random Topics Get Dirty Development Code Q&A Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 18. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Build System build/core/core/build-system.html . build/envsetup.sh showcommands export ANDROID JAVA HOME if non-standard Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 19. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A adb ADBHOST for transport over TCP/IP kill-server remount pull/push logcat shell Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 20. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A hierarchyviewer Display view hierarchy Display view Invalidate/Relayout Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 21. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management 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 Introduction to Android Window System
  • 22. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. 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 Introduction to Android Window System
  • 23. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 24. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 25. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuffers is called to allocate buffers Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 26. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuffers is called to allocate buffers Two dealers are created from client, one for front buffer and one for back buffer Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 27. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuffers is called to allocate buffers Two dealers are created from client, one for front buffer and one for back buffer Two LayerBitmaps are created, initialized with the two dealers Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 28. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Graphics: Memory Management cont. Real flow A client asks for a new surface, createSurface createSurface calls createNormalSurfaceLocked A layer is created and setBuffers is called to allocate buffers Two dealers are created from client, one for front buffer and one for back buffer 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 Introduction to Android Window System
  • 29. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Hello World http://people.debian.org.tw/˜olv/surfaceflinger/demo.tar.gz Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 30. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Many Buffers Surface is double buffered EGLDisplaySurface is double buffered Same technique; Different code pathes, different purposes Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 31. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Double Buffering Sofware v.s. Hardware Memory copy Page flipping Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 32. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Dirty Region Associate buffers with dirty regions Copy back Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 33. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Frame 0 Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 34. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Frame 1 Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 35. Outline Building Blocks Development Under the Hood Code Get Dirty Q&A Frame 2 Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 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 Q&A Chia-I Wu olv@0xlab.org Introduction to Android Window System
  • 37. Outline Building Blocks Under the Hood Get Dirty Q&A Q&A Questions? Chia-I Wu olv@0xlab.org Introduction to Android Window System