【Android System Development】Android framework and source
code structure
Posted On 2023-03-27 10:23:47 439 0 report
1. Android Framework
Android framework hierarchy: Android is divided into 4 layers from bottom to top;
-- Linux kernel layer;
-- Various libraries and Android runtime layers;
-- Apply the framework layer;
-- Application layer;
1. Linux kernel layer
Android's Linux kernel layer consists of the Linux kernel and drivers;
Linux kernel : Android 2.x is based on the Linux 2.6 kernel;
Driver :
-- Display Driver: Framebuffer driver for Linux;
-- Flash Memory Driver: MTD-based Flash driver;
-- Camera Driver: Based on Linux v4l driver;
-- Audio Driver: Based on ALSA driver;
-- Wifi Driver: Driver based on IEEE 801.31 standard;
-- KeyBoard Driver: Acts as a keyboard driver for input devices;
-- Bluetooth Driver: Wireless transmission technology based on IEEE 801.35.1 standard;
-- Binder IPC Driver: Android-specific driver with a separate device node that provides the ability for process
communication;
-- Power Management: Manage information such as battery level;
Parsing Driver:
-- Frame buffer: The video output device contains a video buffer with complete frame data, and the buffer is used
to drive the video display device;
-- v4l (Video for linux) : Camera driver in Linux;
-- ALSA (Advanced Linux Sound Architecture) : Advanced Linux Sound Architecture Driver, this component
provides a sound card driver;
2. Libraries and Android runtime
This layer is divided into two parts: the Android runtime and various libraries;
Introduction to various libraries: These libraries are provided in the form of system middleware , which is
closely related to the application of mobile device platforms;
-- C Standard Library: The lowest-level library of the Android system, which calls the system calls of the kernel
to implement the required functions;
-- Media Framework: Android Multimedia Core, is an OpenCore framework based on PacketVideo, with
function 1 audio and video playback, function 2 audio and video recording;
-- SGL : 2D engine;
-- SSL (Secure Socket Layer): It mainly provides security support for data communication between TCP/IP
protocol and application layer protocol.
-- OpenGL ES: 3D Engine;
-- Surface Management (interface management tool) : Manage the functionality of the display subsystem;
-- SQLite : Embedded Database ;
-- WebKit: web browser kernel;
-- FreeType: provides bitmap and vector font functionality;
Differences between Dalvik VM and JVM:
-- Execution file: JVM executes .class standard bytecode file, Dalvik virtual machine executes .dex file;
-- The biggest difference: JVM is a stack-based virtual machine, and Dalvik virtual machine is a register-based
virtual machine, which can be better optimized according to the hardware;
3. Application framework layer
Application framework layer: This layer provides the APIs used by the application, including various UI
components and other components, including the following components;
-- Activity : the main activity interface;
-- BroadcastReceiver : Broadcast receiver;
-- Service : service;
-- ContentProvider: Content provider;
4. Application layer
This layer is mostly an apk installer;
2. Android source code structure
The analysis is based on the source code of the android-2.3.4_r1 version;
Android Source Code Structure Classification :
-- Core section : This part is the foundation on which the Android system is built, which is saved in the file of the
root directory;
-- Extension project: Use parts of other open source projects;
-- Package section : provides Android applications, four major components etc., in the package directory;
1. Root (/)
bionic : source code of the base library, C runtime support library libc, libm, libdl, dynamic linker;
bootable/bootloader/legacy: kernel bootloader, the program that runs before loading the kernel;
build: compile and configure the required scripts and tools;
dalvik : Java Virtual Machine in Android, which provides the basis for running Android applications;
development: templates and tools required for program development, at a high level;
external : Other open-source extension libraries used;
frameworks: application framework layer, four major components, etc.;
hardware : hardware-related libraries;
kernel : Linux kernel source code;
packages : Android various applications;
prebuilt: Compile prebuilt scripts on various platforms;
recovery : related to the Android system recovery function;
system: Android underlying library;
Makefile: The Makefile compiled from the entire Android source code;
2. development directory (/development)
apps : Android app templates;
build: compile the script template;
Host : Some tools for the Windows platform;
samples : sample programs, simple Android programs, which can be used as templates;
3. external directory (/external)
opencore: Android multimedia framework core;
webkit : Android web browser core;
sqlite : Android database system core;
openssl: Secure Socket Layer, is a network protocol that provides secure support for data communication;
4. frameworks
base: the basic content of the Android core framework library;
opt : optional part;
base directory contents :
-- cmds : important commands;
-- core: core library;
-- data : font sound data file;
-- docs : documentation;
-- graphics : graphics related;
-- include : header file;
-- keystore : data signing certificate;
-- libs : library;
-- location : Region Library;
-- media : media-related libraries;
-- obex : Bluetooth-related libraries;
-- opengl : 3D graphics library;
-- packages : set up TTS V** and other libraries;
-- sax : XML parsing;
-- services : a variety of services;
-- telephony: telephone communication management;
-- test-runner : related to testing tools;
-- test : various tests;
-- tools : various tools;
-- v** :
-- wifi :
5. Packages directory (/packages)
Apps : various applications in Android;
Providers : Holds content provider information;
inputmethod : input method;
wallpapers : wallpaper;