Skip to content

Instantly share code, notes, and snippets.

@jieyu
jieyu / AndroidViewInvalidation.md
Created March 9, 2013 21:24
Describe how View.invalidate() is processed in Android to refresh a widget.

How View.invalidate() is processed in Android

This document is based on the code of android-4.1.1_r6 (Jelly Bean).

First, the invalidate() call will be propagated back to the root of the view hierarchy. During the propagation, the system determines the dirty area that needs to be redrawn. The propagation will eventually reach ViewRootImpl.

frameworks/base/core/java/android/view/View.java

10219   void invalidate(boolean invalidateCache) {

... ...

@jieyu
jieyu / AndroidRepoBranch.md
Last active December 11, 2015 05:29
How to branch a topic from a given version of Android source code.

Branch a topic using repo in Android

This document is based on the code of android-4.1.1_r6 (Jelly Bean).

First, download the source code tree using repo tool:

# mkdir android-4.1.1_r6.1
# cd android-4.1.1_r6.1
# repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r6.1

repo sync

@jieyu
jieyu / AndroidBuildKernel.md
Last active March 11, 2017 16:42
How to build Android OS kernel from its source code.

How to build Android OS kernel from its source code.

This document is based on the code of android-4.1.1_r6 (Jelly Bean).

# cd $ANDROID_SRC_DIR
# . build/envsetup.sh
# set_stuff_for_environment
# mkdir kernel
# cd kernel
@jieyu
jieyu / AndroidConcurrencyEvent.md
Last active December 11, 2015 01:48
How to track concurrency related events (e.g. thread creation, monitor entering, etc.) in Android.

How to track concurrency related events in Android

This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).

Thread forking

libcore/luni/src/main/java/java/lang/Thread.java

1043     public synchronized void start() {                                           

1044 if (hasBeenStarted) {

@jieyu
jieyu / AndroidStaleOdexDep.md
Last active October 16, 2017 10:16
Solving the unbootable Android problem caused by stale ODEX dependencies.

Stale ODEX dependencies cause unbootable Android

This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).

Suppose that you want to customiz your android system, you may want to modify /system/framework/framework.jar (source files are in the directory frameworks/base). During development, let's assume that you just did a full build, and you decide to make some changes to some source files. After that, you want to build again. Ideally, the building system can correctly re-build everything that is dependent on the changes you just made. However, seems that the android building system does not do it properly. You will get an unbootable image caused by mismatched dex signature. If you check the log when system boots, you will see an error message like the following:

07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/apache-xml.jar odex has stale dependencies

The reason is

@jieyu
jieyu / AndroidInputEventPropagation.md
Created December 11, 2012 21:40
How a user input event is propagate in the Android framework and how it is delivered to the corresponding event handler.

Android Input Event Propagation

This document discusses how an input event from user (e.g. user key stroke) is propagated in Android framework, and how it is delivered to the corresponding event handler in the application.

This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).

For each application, a ViewRootImpl object is created to handle communications with the remote system WindowManagerService object. The communication is through a Linux pipe which is encapsulated in an InputChannel object (mInputChannel field in class ViewRootImpl). The ViewRootImpl object also registers an instance of InputEventReceiver when the first View object is registered with it.

frameworks/base/core/java/android/view/ViewRootImpl.java +482