Akagi201
8/24/2014 - 5:00 PM

android-source.md

outline

  • Android Architecture
  • Compile Android include Kernel
  • Android FIle System
  • Android Emulator
  • Application/Framework -> JNI -> Native C/C++

What is Android

  • Android包括operating system, middleware和applications.
  • kernel: linux
  • middleware: libraries, VM, Application, Framework.
  • Key applications: Phone, Browser...

GNU/Linux vs Android/Linux (cont)

  • Android uses Android/Linux, not GNU/Linux.
  • No native windowing system.
  • No glibc support. (为了避免GPL的麻烦)
  • Not include the full set of standard Linux utilities.
  • User space has 3 ways to access kernel space on Linux: /dev, /sys, /proc

Linux Kernel

  • Based on Linux Kernel 2.6.
  • Official first release using Linux 2.6.25 in 2008/9.
  • Patch of kernel enhancements for Android.

How to Find Android Patch in Linux Kernel

  • 两种方法: "1. 暴力法; 2. ctags".
  • find . -name "*" | xargs grep "Google, \Inc"
  • Drivers
  • Qualcomm MSM series support.
  • 改进, 文件只列一次: find . -name "*" | xargs grep -i "android" | sed -e 's/:.*$//g' | uniq

Kernel Enhancements for Android

Why Linux Kernel

  • Great memory and process management
  • Permission-based security model
  • Proven driver model
  • Open source

Native Libraries

  • Bionic libc
  • Function libraries
  • Native servers

Bionic Libc

  • Custom libc implementation, optimized for embedded use.
  • Keep GPL out of user-space.
  • Smaller and faster.
  • Not Support certain POSIX features.
  • Not compatible with GNU Libc

Function Libraries

  • Media framework
  • Based on PacketVideo OpenCORE platform
  • Support standard video, audio, still-frame formats.
  • Support for hardware / software codec plug-ins.
  • SQLite
  • Light-weight transactional dasta store.
  • Webkit
  • Based on open source WebKit browser engine.

Native Servers

  • Surface manager
  • Provides system-wide surface "composer", handling all surface rendering to frame buffre device.
  • Can use OpenGL ES and 2D hardware accelerator for its compositions.
  • Double-buffering using page-flip.
  • Audio manager
  • Manages all audio output devices.
  • Processes multiple audio streams into PCM audio out paths.

Dalvik Virtual Machine

  • Different with Java virtual machine.
  • Register based.
  • Customize for specific platform.
  • Java .class/.jar files converted to .dex at build time, not runtime.
  • Uses runtime memory very efficiently.

Application Framework / Applications

  • All applications are written in Java language.
  • Portability.

HAL(Harware Abstraction Layer)

  • User space C/C++ library.
  • Defines the interface that Android requires hardware drivers to implement.
  • Why user-space HAL
  • Avoid to expose proprietary IP unser GPL.

HAL Issues

  • Interface
  • Software layering
  • mmap
  • ISP
  • Synchronization
  • Performance

Android Project Layout

Core projects

ProjectDescription
bionicC runtime: libc, libm, libdl, dynamic linker
bootloader/legacyBootloader reference code
buildBuild system
dalvikDalvik virtual machine
developmentHigh-level development and debugging tools
frameworks/baseCore Android app framework libraries
frameworks/policies/baseFramework configuration policies
hardware/libhardwareHardware abstraction library
hardware/riiRadio interface layer
kernelLinux kernel
prebuiltBinaries to support Linux and Mac OS builds
recoverySystem recovery environment
system/bluetoothBluetooth tools
system/coreMinimal bootable environment
system/extrasLow-level debugging/inspection tools
system/wlan/tiTi 1251 WLAN driver and tools

Recursive Make vs Independent Make