[Android General] llrraa2010:
1. run envsetup.sh

USER-NAME@MACHINE-NAME:~/Android$ . ./build/envsetup.sh

after this, there would be some extra commands available:

- croot: Changes directory to the top of the tree.

- m: Makes from the top of the tree.

- mm: Builds all of the modules in the current directory.

- mmm: Builds all of the modules in the supplied directories.

- cgrep: Greps on all local C/C++ files.

- jgrep: Greps on all local Java files.

- resgrep: Greps on all local res/*.xml files.

- godir: Go to the directory containing a file.

2. use mmm to build the module, such as Email app:

USER-NAME@MACHINE-NAME:~/Android$ mmm packages/apps/Email/

After building, there would be one Email.apk in out/target/product/generic/system/app, where all app files are located here. Also, out/target/product/generic/system/bin for exexcutable, out/target/product/generic/system/lib for library, and out/target/product/generic/system/lib/hw for HAL interface files.

3. repack system.img

USER-NAME@MACHINE-NAME:~/Android$ make snod

4. run emulator

USER-NAME@MACHINE-NAME:~/Android$ emulator

about "inside android"

Hi, all.

As experienced android developers or just beginners, sometimes you might have questions about what's going on inside android. Such as how activity starts, how service starts, etc. If we look into the code, we might have the answer, but it takes time and much effort. In fact, there's millions of lines of source code in android. Fortunately, Shengyang Luo wrote a book in chinese to clarify all these questions, with all the related knowledge he got in these years as an experienced engineer of linux/android. Now, he and I decide this book belongs to the android family, so to make more people get benefit from it, we will rewrite it in English.

Also, we want this book to be more adapted to your need, we might share the outline and part of the content of the book here, so that we all can discuss it while rewriting it. We might change the book according to your advice. For example, there might be more details for the parts you are most interested. To do this, we will have pilot PPTs and passages soon. The pilot topics would be as below:

Android design philosophy--everything is component

Initializing a Build/developing/debugging Environment for Android

Android architecture

Hardware Abstraction Layer(HAL)

drivers specific to android

process management

messaging handling

input handling

UI architecture

resource management framework

Dalvik virtual machine

Which is most interested to you? Please share with us, and we will make it available ASAP.

We haven't talked with any press for publishing yet. So if any press is interested in publishing this book, please contact me. As you all know, writing is a tough job, especially when the book is regarding such a complicated android os system, so cheers, encouragement and funding are welcomed badly. Funding would help us not worry about making a living and dedicate to the writing or even hire some people to accelerate the progress. For funding, please visit indiegogo.com and search "inside android".

The book would have 3 parts: say hello to android, drivers specific to android and understanding android in scenes. The first 2 parts are foundation knowledge for the third part, which is the major part of the book.

Part I say hello to android includes 3 chapters, and introduces how to download the source code, build it, run it, smart pointer and Hardware Abstraction Layer(HAL). Since smart pointer is widely used in the native code of application framework, it would be very helpful if we get to know it before we dive into the scenes. Knowing HAL would help us understand the architecture of android, and then make the third part easier to learn.

Part II drivers specific to android also includes 3 chapters, introducing 3 drivers specific to android: Logger Driver, Binder IPC Driver and Ashmem Shared Memory Driver. No doubt, these 3 drivers, especially the Binder IPC Driver, are the foundation of android. knowing about them would definitely help understand android.

Part III understanding android in scenes includes more than 10 chapters, and introduces android in different scenes, such as the start of something(activity, service, zygote, service manager, etc.), process management, messaging handling etc.

The book is based on android 2.3. If needed, we can rewrite it on newer version.

Below is the outline of the book:

Part I: say hello to android

chapter 1　prerequisite

1.1　reference books on Linux kernel

1.2　reference books on Android application developing

1.3　download, build and run Android source code

1.3.1　download Android source code

1.3.2　build Android source code

1.3.3　run Android emulator

1.4　download, build and run Android kernel source code

1.4.1　download Android kernel source code

1.4.2　build Android kernel source code

1.4.3　run Android emulator

1.5　develop one Android application(example)

1.6　build and pack Android module independently

1.6.1　mmm: Builds all of the modules in the supplied directories

1.6.2　build one Android module independently

1.6.3　repack Android images

chapter 2 Hardware Abstraction Layer(HAL)

2.1　develop Android hardware driver

2.1.1　implementation of one kernel driver

2.1.2　modify Kconfig of the kernel

2.1.3　modify Makefile of the kernel

2.1.4　build the driver

2.1.5　test the driver

2.2　test the driver with C executable

2.3　develop HAL module

2.3.1　specification for HAL module

2.3.2　interface for HAL module

2.3.3　load the HAL module

2.3.4　access permission for the hardware

2.4　develop service to the Android hardware

2.4.1　defite the service interface to hardware

2.4.2　implementation of the service

2.4.3　JNI interface for the service

2.4.4　start of the service

2.5　Android application on the service to hardware

chapter 3 smart pointer

3.1　light weight pointer

3.1.1　implementation

3.1.2　example

3.2　strong pointer and weak pointer

3.2.1　strong pointer

3.2.2 weak pointer

3.2.3 example

Part II: drivers specific to android

chapter 4 Logger driver

4.1　Logger format

4.2　Logger driver

4.2.1　data structure

4.2.2　initialization

4.2.3　open the Logger driver

4.2.4　read the log

4.2.5　write the log

4.3　runtime library for the Logger driver

4.4　log interface for C/C++

4.5　log interface for Java

4.6　Logcat tool

4.6.1　data structure

4.6.2　initialization

4.6.3　read the log

4.6.4　output the log

chapter 5 Binder IPC Driver

5.1　Binder driver

5.1.1　data structure

5.1.2　initialization

5.1.3　open

5.1.4　mapping to the memory

5.1.5　kernel cache management

5.2　runtime library for Binder IPC Driver

5.3　example for Binder IPC Driver application

5.4　counting for Binder object reference

5.4.1　lifecycle of Binder local object

5.4.2　lifecycle of Binder instance

5.4.3　lifecycle of Binder reference

5.4.4　lifecycle of Binder proxy

5.5　Binder object death notification

5.5.1　register death notification

5.5.2　send death notification

5.5.3　unregister death notification

5.6　start of Service Manager

5.6.1　open and mapping on Binder

5.6.2　register as Binder context manager

5.6.3　wait for the Client request in loop

5.7　getting the Service Manager proxy

5.8　start of Service

5.8.1　register Service

5.8.2　start of Binder thread pool

5.9　how to get Service proxy

5.10　Java interface for Binder IPC Driver

5.10.1　getting the Java proxy of Service Manager

5.10.2　define the Java service

5.10.3　start of Java service

5.10.4　getting Java service proxy

5.10.5　calling Java service

chapter 6 Ashmem Shared Memory Driver

6.1　Ashmem driver

6.1.1　data structure

6.1.2　initialization

6.1.3　open

6.1.4　mapping to the memory

6.1.5　lock and unlock

6.1.6　recycle

6.2　Ashmem interface in runtime library cutils

6.3　C++ interface for Ashmem

6.3.1　MemoryHeapBase

6.3.2　MemoryBase

6.3.3　example

6.4　Java interface for Ashmem

6.4.1　MemoryFile

6.4.2　example

6.5　how Ashmem shares memory

Part III: understanding android in scenes

chapter 7 start of Activity

7.1　Activity example

7.2　start of root Activity

7.3　start of child Activity in the same process

7.4　start of child Activity in the new process

chapter 8 start of Service

8.1　Service example

8.2 start of Service in the same process

8.3　start of Service in the new process

chapter 9 Broadcast

9.1　example

9.2　register

9.3　send

chapter 10 Content Provider

10.1　Content Provider example

10.1.1　ArticlesProvider

10.1.2　Article

10.2　start of Content Provider

10.3　data sharing of Content Provider

10.3.1　data sharing model

10.3.2　data transmission

10.4　Content Provider's notification for data Change

10.4.1　register ContentObserver

10.4.2　send notification for data Change

chapter 11 start of Zygote and System process

11.1　start script of Zygote process

11.2　start of Zygote

11.3　start of System

chapter 12 start of Android application

12.1　creation of application process

12.2　start of Binder thread pool

12.3　creation of message loop

chapter 13 message handling

13.1　creation of message queue

13.2　message cycle

13.3　message sending

13.4　message handling

chapter 14 keyboard message handling

14.1　keyboard message handling model

14.2　start of InputManager

14.2.1　creation of InputManager

14.2.2　start of InputManager

14.2.3　start of InputDispatcher

14.2.4　start of InputReader

14.3　register InputChannel

14.3.1　creation of InputChannel

14.3.2　register InputChannel of server side

14.3.3　register the window of currently activated application

14.3.4　register InputChannel of client side

14.4　Dispatch of the keyboard message

14.4.1　InputReader gets keyboard event

14.4.2　InputDispatcher dispatch keyboard event

14.4.3　the window of currently activated application gets keyboard message

14.4.4　InputDispatcher gets notification when the keyboard event handling is done

14.5　unregister InputChannel

14.5.1　destroy application window

14.5.2　unregister InputChannel of client side

14.5.3　unregister InputChannel of server side

chapter 15 message loop model of Android application thread

15.1　message loop model of application main thread

15.2　message loop model of nongraphic application child thread

15.3　message loop model of graphic application child thread

chapter 16 installation and showup of Android application

16.1　installation of application

16.2　showup of application

chapter 17 UI system

17.1 UI architecture

17.2 application UI framework

17.3 WindowManagerService

17.4 SurfaceFlinger

17.5 Multiple Display support

chapter 18 resource management framework

18.1 resource management framework

18.2 compilation of resource

18.3 search for resource

chapter 19 Dalvik virtual machine(DVM)

19.1 introduction

19.2 start of DVM

19.3 execution of DVM

19.4 register JNI methods

19.5 DVM process

19.6 DVM thread