Saturday, March 2, 2019

Old Android note: Andorid source code folder structure


This is from my old (maybe 8+ years ago) Android note.
Refer to http://elinux.org/Android_Source_Code_Description. Explanation from Stackoverflow: Here is short version of what you will find when you download the Android source. I will leave out some minor directories and dig deeper into a couple of the important ones. Basically what you will get (based on the current Ice Cream Sandwich release), in alphabetical order:
  • Bionic - the C-runtime for Android. Note that Android is not using glibc like most Linux distributions. Instead the c-library is called bionic and is based mostly on BSD-derived sources. In this folder you will find the source for the c-library, math and other core runtime libraries. The core idea behind Bionic's design is: KEEP IT REALLY SIMPLE.
  • Bootable - boot and startup related code. Some of it is legacy, the fastboot protocol info could be interesting since it is implemented by boot loaders in a number of devices such as the Nexus ones.
  • Build - the build system implementation including all the core make file templates. An important file here is the envsetup.sh script that will help you a lot when working with the platform source. Running this script in a shell will enable commands to setup environment variables, build specific modules and grep in source code files.
  • Cts - the compatability tests. The test suite to ensure that a build complies with the Android specification.
  • Dalvik - the source code for the implementation of the Dalvik Virtual Machine
  • Development - projects related to development such as the source code for the sdk and ndk tools. Normally not a folder you touch when working with the platform for a target.
  • Device - product specific code for different devices. This is the place to find hardware modules for the different Nexus devices, build configurations and more.
  • External - contains source code for all external open source projects such as SQLite, Freetype and webkit.
  • Frameworks - this folder is essential to Android since it contains the sources for the framework. Here you will find the implementation of key services such as the System Server with the Package- and Activity managers. A lot of the mapping between the java application APIs and the native libraries is also done here.
  • Hardware - hardware related source code such as the Android hardware abstraction layer specification and implementation. This folder also contains the reference radio interface layer (to communicate with the modem side) implementation. Mostly code here will be built as module into system.img but not part of boot.img.
  • (Kernel) - not part of the default source download but you can get access to this code either by downloading it manually or by adding the repository to the repo tool. Contains the sources for the Android version of the Linux kernel. Will be built into boot.img.
  • Out - the build output will be placed here after you run make. The folder structure is out/target/product/. In the default build for the emulator the output will be placed in out/target/product/generic. This is where you will find the images used by the emulator to start (or to be downloaded and flashed to a device if you are building for a hardware target).
  • Packages - contains the source code for the default applications such as contacts, calendar, browser.
  • Prebuilt - contains files that are distributed in binary form for convenience. Examples include the cross compilations toolchains for different development machines.
  • System - source code files for the core Android system. That is the minimal Linux system that is started before the Dalvik VM and any java based services are enabled. This includes the source code for the init process and the default init.rc(/system/core/rootdir/init.rc) script that provide the dynamic configuration of the platform


    Linux Kernel

    The Android Linux kernel includes enhancements to the Linux 2.6 kernel that provide additional drivers to support the Android platform, including:
    • Binder: an OpenBinder-based driver to facilitate inter-process communication (IPC) in the Android platform.
    • Android Power Management: a light weight power management driver built on top of standard Linux power management but optimized for embedded systems.
    • Low Memory Killer: Based on hints from the userspace, the low memory killer can kill off processes to free up memory as necessary. It is designed to provide more flexibility than the Out Of Memory (OOM) killer in the standard kernel.
    • Logger: A light weight logging device used to capture system, radio, logdata, etc.
    • USB Gadget: Uses the USB function framework.
    • Android/PMEM: The PMEM (physical memory) driver is used to provide contiguous physical memory regions to userspace libraries that interact with the digital signal processor (DSP) and other hardware that cannot cope with scatter-gather.
    • Android Alarm: A driver which provides timers that can wake the device up from sleep and a monotonic timebase that runs while the device is asleep.
    Look for Android-specific enhancements in the following directories:
    • /drivers/android
    • /drivers/misc
    • /include/linux

    Android Platform and Applications

    The following list outlines the directory structure found within the device branch of Android source code:
    • apps : Core Android applications such as Phone, Camera, and Calendar.
    • boot : Reference Android bootloader and other boot-related source code.
    • commands : Common Android commands, the most important of which is the runtime command, which does much of the initialization of the system.
    • config : System-wide makefiles and linker scripts.
    • content : Standard Android ContentProvider modules.
    • dalvik : Android runtime Virtual Machine (VM).
    • data : Fonts, keymaps, sounds, timezone information, etc.
    • docs : Full set of Android documentation.
    • extlibs : Non-Android libraries. This directory is intended to host unmodified external code. None of the libraries included within this directory rely on Android headers or libraries.
    • ide : Tools for support of the IDE's used to write Android applications.
    • include : Android system headers for inclusion.
    • java : Android core APIs, as well as some external libraries.
    • libs : Android-specific C++ based libraries.
    • partner : Project-specific source code for various proprietary components.
    • prebuilt : Prebuilt tools, like the toolchains and emulator binary.
    • product : Device-specific configuration files. This directory will include a subdirectory for each new device.
    • samples : Sample applications.
    • servers : C++ based system servers.
    • system : Core of the embedded Linux platform at the heart of Android. These essential bits are required for basic booting, operation, and debugging.
    • tests : Platform and application test cases.
    • tools : Tools for building and debugging Android (of particular interest for porting are "adb" and "emulator").

0 Comments:

Post a Comment