Android Source Code Description

From eLinux.org
Revision as of 09:47, 29 October 2012 by Nanikjava (Talk | contribs)

Jump to: navigation, search

Repo tag version - android-4.0.3_r1


1. abi

  • cpp
The content of this directory is not clear what it is about as it contains several C++ files.

2. bionic

Bionic is mainly a port of the BSD C library to our Linux kernel with the following additions/changes:
- no support for locales
- no support for wide chars (i.e. multi-byte characters)
- its own smallish implementation of pthreads based on Linux futexes
- support for x86, ARM and ARM thumb CPU instruction sets and kernel interfaces
  • libc
This directory contains the different architecture that is supported to use bionic, namely - ARM (under the arch-arm/) and x86 (under the arch-x86/ directory). In order to understand in detail on how to add functions or port it to different architecture you want to read the file OVERVIEW.TXT under the docs/ folder
  • libdl
This directory what looks like a ‘stub’ program that are being used during linking process. The main function of the program is to open a library and read the symbol. The file that contains the main functionality is dlfcn.c under the /bionic/linker/ directory
  • libm
Contains Math library. Several architecture are supported inside this directory.
  • libstdc++
  • libthread_db
  • linker
This directory contains utility that is used during linking process. The tool is called Android Dynamic Linker what is does is it assign fix addresses to the library to reduce the size of the library and also increases the loading speed. .

3. bootable

  • legacy/bootloader
This directory contains a sample bootloader for a fictional SoC. The sample code is to show on how to implement a bootloader for a particular SoC. The directory contains a file called fastboot_protocol.txt which outlines the Fastboot protocol implemented by vendor. There is a good detail explanation about the code in the README file
  • diskinstaller
There is no README file or any such file inside this directory that give some information about the content. Looking at the source code it seems to be code written to write image files into partition, not sure for what kind of devices.
  • recovery
This directory contains code for creating recovery program. The code inside shows the different things that needs to be implemented. This can be used as a boilerplate to create your own custom recoveries like the ClockworkMod.
  • applypatch - Applies binary patches to files
  • edify - Contains code that parse update scripts. The language is call ‘edify’ (this is used in conjuction with the updater sub-project)
  • etc - contains sample update script (the file is called update-script)
  • minelf - contains source library that is used by the updater sub-project
  • minui - contains graphical library to be used by the recovery project.The library are mostly utilized for displaying information
  • minzip - library utilized in the recovery project+
  • mtdutils - library utilized for reading & writing to the Flash memory
  • res - contains images that are used as background in the recovery project
  • testdata - test .zip files for testing the update process
  • tools - library that contains misc function that are used by the recovery project. Some interesting function that allow checking of “unclean” reboot.
  • updater - This contains the executable to run the update script

4. build

The main entry point of the build system resides here - envsetup.sh, if you follow the instruction in source.android.com you will see that the first step before you do anything to build Android is to use the command source build/envsetup.sh
The script will check few things to make sure all the needed application available in the local machine. It also setup the devices that can be built, which is extracted from the directory device
  • core
This directory contains the heart of the build system, it consists of a number of files with the .mk extension (Makefile). The entry point of the build is the main.mk file
  • libs
This directory contain a program which is written to replace the “cp” command to be used in Android. Not sure what is the rationale behind the use of this program.
  • target
This directory contains configuration for the target device that you are planning to build for. Looking at the content of this directory it looks like it is being used for emulators. The files inside this directory looks similar with the device directory where it contains .mk file for board specifics.
  • tools
This directory contains a number of tools that can be used as part of the build process. [need to investigate later whether the tools inside this directory is used as part of the build process - document tools that are used in the build process].
atree - this project is a program for file listing or something like the ‘ls’ command. (inside out/host/linux-86/bin)
check_prereq - (inside out/target/product/<device>/system/bin)
fs_config - this project is part of the host tools (inside out/host/linux-86/bin)
releasetools - this project contains python scripts that can be used to sign your .apk, create an OTA file and other release related tasks
rgb2565 - this project is to convert image to a 565raw format (inside out/host/linux-86/bin)
signapk - this project is to sign your .apk file, the project is written in Java code (inside out/host/linux-86/framework)
zipalign - according to the README file “The purpose of zipalign is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. This allows those portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions.” (inside out/host/linux-86/bin)

5. cts

This directory contains compatibility test suite (http://source.android.com/compatibility/cts-intro.html). The test coverage are broken down into different folders to cover different parts of Android.
  • apps
This directory contains applications test suites. The test cases are written in Java and it test different device functionality from application layer such as - USB, sensors, camera, bluetooth, etc
  • development
[contains script file but it does not make sense how it is used in the Android build system]
  • libs
[according to the README file classes were extracted from the http://code.google.com/p/vogar/ project. Looking at the description of the project it is a command line test utility for Java]
  • tests
This directory contains Java test cases testing different kind of things, mostly on features that are available from Java application.
  • tools
This directory contains different kind of tools that are available for you to use. The tools are not used in the build process.
build - there is only 1 .mk file that is used to generate associated test package XML for the cts.
cts-api-coverage
cts-native-xml-generator
cts-reference-app-lib
device-setup
tradefed-host
utils
dex-tools - Java project that reads .dex file, this is quite useful if you need to understand the .dex file format. In the README file it is stated that Eclipse .classpath is available to make it easier for us to import, but can’t find the file anywhere.
dasm - .d file disassembler and assembler
dx-tests - according to the dx-tests.html file “It tests the capabilities of the DX converter in a black-box manner, based on the usual specifications for .class files.”
host - this folder contains test cases to test some of the host applications such as ADB, Session, etc.
signature-tools - This project contains the source code and tests for API signature comparison tools. The project is in Java
vm-tests - Dalvik VM test cases
vm-tests-tf - Similar to vm-tests except there are few difference files.

6. dalvik

  • dalvikvm
This directory contains the main Dalvik class that execute the .dex files
  • dexdump
The "dexdump" tool is intended to mimic "objdump".
  • dexgen
Home of dexgen, the dex code generator project. It provides API for creating dex classes in runtime which is needed e.g. for class mocking. This solution is based on the dx tool and uses its classes extensively.
  • dexlist
List all methods in all concrete classes in one or more DEX files.
  • dexopt
Command-line DEX optimization and verification entry point.
  • docs
Dalvik documentation
  • dvz
  • dx
Home of Dalvik eXchange, the thing that takes in class files and reformulates them for consumption in the VM. It also does a few other things; use "dx --help" to see a modicum of self-documentation.
  • hit
This directory contains program to read HPROF file specific to Android. HPROF is a profiler tool in Android. The application in this directory can be run to read a sample .hprof file in the samples directory.
  • libdex
This directory contains .dex file related tools.
  • libnativehelper
This directory contains support functions for Android's class libraries. These are VM-agnostic native functions that implement methods for system class libraries. All code here:
  • MUST not be associated with an android.* class (that code lives in frameworks/base/).
  • SHOULD be written in C rather than C++ where possible.
Some helper functions are defined in include/nativehelper/JNIHelp.h.
  • opcode-gen
This directory contains sets of defined opcodes and instruction formats for Dalvik.
  • tests
This directory contains test cases to test Dalvik op-codes.


  • tools
This directory contains Dalvik related tools
  • dexdeps -This tool dumps a list of fields and methods that a DEX file uses but does not define. When combined with a list of public APIs, it can be used to determine whether an APK is accessing fields and calling methods that it shouldn't be. It may also be useful in determining whether an application requires a certain inimum API level to execute.
  • dmtracedump - This directory contains the dmtrace tool
  • gdbjithelper - This directory contains an interesting debugging tool to debug certain behaviour that could not be catch easily. There is an instruction on how to use it inside README file
  • hprof-conv - This directory contains an application to strip Android-specific records out of hprof data, back-converting from 1.0.3 to 1.0.2. This removes some useful information, but allows Android hprof data to be handled by widely-available tools (like "jhat").
  • unit-tests
  • vm
This directory contains the core of the Dalvik code.

7. development

  • apps
This directory contains application that are not part of the deployed app in the OS. There are some useful application such as widget builder, etc
  • build
  • cmds
This directory contains the monkey tool that allows you to inject key events into an app.
  • data
This directory contains network carrier information.
  • docs
This directory contains copyright templates
  • host
This directory contains Windows binary files for USB.
  • ide
This directory contains IDE specific information/configuration. Eclipse, EMacs, IntelliJ and XCode are the IDEs supported.
  • libraries
From the README.txt
Stereo Camera Libraries for Android. This SDK component contains static libraries for computing the depth map of a pair of stereo images. To use the libraries, simply copy them as static libraries into your project.
  • ndk
This directory contains NDK (Native Development Kit) for Android. This particular directory is not build as part of the Android build process.
  • pdk
This directory contains PDK (Platform Development Kit) for Android. It contains documentation rather than any code.
  • samples
This directory contains Android application sample files. There are a lot of sample projects that can be used by developers.
  • scripts
Some Google App Engine specific scripts.
  • sdk
This directory contains .properties file related to SDK, can’t figure out what exactly it is used for as there aren’t that much information inside.
  • sdk_overlay
Overlay resource files that are used for different device
  • testrunner
Utility to run the test cases based on Python.
  • tools
  • apkcheck - This directory contains Android APK Checker utitlity.This compares the set of classes, fields, and methods used by an Android application against the published API. It identifies and reports the use of any unpublished members or methods.
  • axl - TCP and HTTP tests, the testcase is written in Python.
  • emulator
  • etc1tool
  • findunused
  • glesv2debugger - Debugger for debugging GLES2
  • hosttestlib
  • idegen - automatically generates Android IDE configurations for IntelliJ IDEA and Eclipse. Your IDE should be able to compile everything in a reasonable amount of time with no errors.
  • jdwpspy
  • labpretest - The labpretest.sh script is designed to emulate a typical automated test lab session. It puts a device into bootloader mode, reboots into bootloader mode, determines device type, erases user cache, flashes a generic userdata image, updates the bootloader image, updates the radio image, updates the system image and reboots, sets up for a monkey run and finally runs a random monkey test. It will repeat this based on an optional parameter(-i) or default to 100 times. It will detect if it is in a low battery situation and wait for it to charge again.
  • line_endings
  • mkstubs - is small tool that takes a given JAR and filters all the private stuff we don't want to expose, e.g.: remove all private members, only include a subset of classes, exclude specific classes, fields or methods.
  • templates - This directory contains Android source code templates for building Android application.
  • yuv420sp2rgb
  • tutorials
This directory contain a Notepad tutorial application development tutorial.

8. device

  • common
This directory contains gps information and also a script that allows you to extract proprietary binary files from your phone to be part of the build process.
  • generic
This directory contains the generic device configuration that is called ‘goldfish’. This is the device classification used when building the emulator.
  • google
This directory contains the Android Accessories Kit code. It contains a demokit Android app that allows you to control the ADK board. The ADK firmware can be check out here http://code.google.com/p/microbridge/. There is a good article about this http://romfont.com/2011/05/12/google%E2%80%99s-open-accessory-development-kit-on-standard-arduino-hardware/
  • sample
This directory contains a full example of writing your own Android platform shared library, without changing the Android framework. It also shows how to write JNI code for incorporating native code into the library, and a client application that uses the library. This example is ONLY for people working with the open source platform to create a system image that will be delivered on a device which will include a custom library as shown here. It can not be used to create a third party shared library, which is not currently supported in Android.
  • samsung
This directory contains Samsung specific configuration
  • ti
This directory contains TI Pandaboard configuration for build process.

9. docs

  • source.android.com
Contains tutorials, references, and miscellaneous information relating to the Android Open Source Project (AOSP). The current iteration of this site is fully static HTML (notably lacking in javascript and doxygen content), and is and/or was maintained by skyler (illustrious intern under Dan Morrill and assistant to the almighty JBQ).

external android-mock Android Mock is a wrapper for EasyMock (2.4) which allows for real Class mocking on an Android (Dalvik) VM. All methods on Android Mock are syntactically equivalent to EasyMock method calls, and will delegate calls to EasyMock, while performing the required transformations to avoid Dalvik VM troubles.

antlr From the project website http://www.antlr.org/

ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.

apache-harmony Apache Harmony software is a modular Java runtime with class libraries and associated tools.

apache-http HTTP API for Java from Apache

apache-xml From project website http://xml.apache.org/xalan-j/

Xalan-Java is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. It implements XSL Transformations (XSLT) Version 1.0 and XML Path Language (XPath) Version 1.0 and can be used from the command line, in an applet or a servlet, or as a module in other program.

astl ASTL (Android STL) is a slimmed-down version of the regular C++ STL.

bison This directory contains the Bison parser generator.

blktrace This directory contains Block IO Tracing. blktrace was integrated into the mainline kernel between 2.6.16 and 2.6.17-rc1. The website http://brick.kernel.dk/snaps/