Skip to main content

Android UI Internal: The Design of SurfaceFlinger , Design Pattern's perspective

This slide was for a training I conducted around a year ago for our internal team and I feel more people might find it useful, especially those who also works in Android graphic framework.

Android native graphic system, with SurfaceFinger sitting in the center, is rather sophisticated and it takes time to fully appreciate how all pieces working together. Despite of the complexity, I often marvel at the elegance of the whole architecture design. To active this elegance,  design patterns play a critical role.

In this presentation, I introduced several design patterns: Observer, Proxy, Command Pattern, Thread Pool, Producer-Consumer, and Active Object. The first three are introduced in GOF classic . The last three are concurrent patterns and you may want to goole a little bit.  Furthermore, I illustrated how SurfaceFlinger utilized and evolved those pattens to build a larger architecture to meet the requirements needed by graphic system. I also explained the sequence of how an update in user application trigged the composition of SurfaceFlinger - a user case that links every pieces together.

I wish you find it useful.


Popular posts from this blog

Android Camera2 API Explained

Compared with the old camera API, the Camera2 API introduced in the L is a lot more complex: more than ten classes are involved, calls (almost always) are asynchronized, plus lots of capture controls and meta data that you feel confused about.

No worries. Let me help you out. Whenever facing a complex system need a little bit effort to understand, I usually turns to the UML class diagram to capture the big picture.

So, here is the class diagram for Camera2 API.




You are encouraged to read this Android document first and then come back to this article, with your questions. I'll expand what is said there, and list the typical steps of using camera2 API. 

1. Start from CameraManager. We use it to iterate all the cameras that are available in the system, each with a designated cameraId. Using the cameraId, we can get the properties of the specified camera device. Those properties are represented by class CameraCharacteristics. Things like "is it front or back camera", "outpu…

Java Collections Framework Cheat Sheet

Java Collections Framework (JCF) implements the Abstract Data Type  for Java platform. Every serious Java programmer should familiar himself on this topic and be able to choose the right class for specific need.  A thorough introduction to JCF is not the target of this small article and to achieve that goal you can start with this excellent tutorial . 

Instead, I'd like to
1) Provide an overview of JCF's classes ,   2) Provide a cheat sheet you can post in your cubicel for daily reference, 3) Underline the relationship between JCF's implementation and the data structure and algorithm you learned in your undergraduate course

With these goals in mind, I came up following diagram - Java Collection Cheat Sheet. You can click it to zoom in. There is no necessity for more explanation once your familiar with UML class diagram and have a basic understanding of common data structures.


Android Security: An Overview Of Application Sandbox

The Problem: Define a policy to control how various clients can access different resources. A solution: Each resource has an owner and belongs to a group.Each client has an owner but can belongs to multiple groups.Each resource has a mode stating the access permissions allowed for its owner, group members and others, respectively. In the context of operating system, or Linux specifically, the resources can be files, sockets, etc; the clients are actually processes; and we have three access permissions:read, write and execute.