Android System Development Note 1:android System OverviewAndroid Four layer architecture:
1. Linux kernel&driver Layer
A. Relies on the Linux 2.6 kernel, which contains security. Memory management. Process management, network protocol stack. Drive models, etc.
B.android himself joined the drive, Binder IPC Drive, display driver, input device driver. Audio system driver, camera driver, WiFi drive. Bluetooth driver, power management, etc.
2. Android local library & Java Execution Environment layer
Android Local library (c/C + +)
Bionic: C system function library customized for embedded devices libc
Opencore: Multimedia Library
... ...
Java Execution Environment
Dalvik is a Java virtual machine in Android that supports executing multiple virtual machine instances at the same time.
Every Android app is executed in its own process. Have a separate instance of the Dalvik virtual machine;
All Java classes are compiled by the Java compiler and then transferred to the. Dex format by the DX tool in the SDK for execution by the virtual machine
3. Android Application Framework Layer
Provides a range of services and systems for the top-level applications, including:
Views: such as lists, girds, buttons and other UI elements;
Content Providers: Data sharing between applications;
Resource Manager: Provides access to local strings, graphics, layout, and other resources;
Notification Manager: Display your own definition tips in the status bar
Activity Manager: Managing the Activity life cycle
4. Android Application Layer
Java-based applications that contain both the core applications provided by the Android system (e-mailclient. SMS, calendar, browser. Address Book, etc.), including user-developed Android apps
Three development modes for Android systems:
1. Android App Development
Application-level development based on Android-provided system APIs (third-tier Java framework). Usually based on the development of the Android SDK, you can
2. Android System Development
Usually involves the development of various layers of user space: C or C + + local library, JNI layer, Java class Library, application layer
3. Android Porting Development
Driver development for related devices in Linux. For example, LCD, touch screen, keyboard, audio, camera. Bluetooth and so on.
As well as the development of the hardware abstraction layer, the hardware abstraction layer is in user space. Between the drive and the Android system
Android Development Aids
AAPT: Used to build a zip-compatible package, such as zip,jar,apk
ADB (Android Debug Bridge), can be connected via network or USB. Assuming that you are using network mode, you need to set the ADBHOST environment variable (? )
Aidl (Android Interface Description Language): Code that generates inter-process interfaces, such as interfaces that may be used by the service
DDMS (Dalvik debug Monitor Service): Can manage processes and assist in debugging on simulators or devices
Draw 9-patch:ninepatch is a non-vector graphics natural stretch processing method that is unique to the Android platform that helps the regular graphics not scale when stretched; Draw 9-patch agrees to create Ninepatch graphics using WYSIWYG methods
Hierarchy Viewer: Used to debug and optimize the user interface
Mksdcard: Create disk image to simulate SD card in simulator environment
TraceView: Ability to graphically visualize the trace log for Android applications
Android System Process
Init process (Process 1th), the parent process is process number No. 0. Run the Init program under the root folder, which is the user space process
——->/system/bin/sh
——->/system/bin/mediaserver
——-> Zygote
————— –> System_server
————— –>com.android.phone
————— –>android.process.acore (Home)
... ...
Kthreadd process (process 2nd), the parent process is process number No. 0. is a kernel process, and other kernel processes are directly or indirectly using it as the parent process
Use of Logcat
http://www.zooyoo.org/?p=10560
Android System development note 3-android kernel and driver
Android uses Linux2.6 and has fewer modifications to the standard kernel, but adds some content, such as the Yaffs file system
Android Dedicated driver
Ashmem Anonymous Shared memory
Node name/dev/ashmem, which provides the memory allocation mechanism for the user space program, realizes the function of similar malloc.
Code path in kernel: kernelmm/ashmeme.c
The C Libutils Library encapsulates it: SYSTEM/CORE/LIBCUTILS/ASHMEME-*.C
Binder
Node name/dev/binder, which provides IPC support for user programs, is the main IPC mode in Android
The Libutils tool library for user space (framework/base/libs/utils) and the Service Manager daemon call the Binder interface to provide support for the entire system
Logger
Three device nodes:/dev/log/main,/dev/log/event,/dev/log/radio
Code in kernel: KERNEL/DRIVERS/MISC/LOGGER.C
Call logger driver in user space Logcat (system/core/logcat)
Device drivers used by Android
Framebuffer Display Driver
For embedded systems, the framebuffer is usually driven by an LCD controller or other display device;
FB is a character device, usually its device node is/DEV/FBX, but using/dev/graphic/fb0 in Android, the device node is created by the Init process itself, is called by the Libui library ;
FB driver uses IOCTL more in user space. Mmap,write and other file system interfaces, the IOCTL is used to obtain/set the information. Mmap is able to map Framebuffer's memory to user space. Write outputs the display directly in written form
Event input Device driver
The event driver is a generic input device driver that now supports the mouse. Keyboard, touch screen and many other input devices;
The device node of the event device in the file system is:/dev/input/eventx, created by the Init process, and used by the public Libui library.
User space Operation event device using File system interface such as Read,ioctl,poll
V4L2 Camera & Video Driver
The V4L2 driver is capable of supporting both video capture and video output, but the hardware structure varies greatly. Therefore, two kinds of drivers in a system need to be implemented separately;
Instead of using the V4L2 driver directly in Android, use the camera or overlay hardware abstraction layer to
User space using IOCTL, mmap operation V4l2
OSS Audio Driver
The Open sound system is a character-based audio driver, user space with ioctl/read/write operation/dev/mixer,/DEV/DSP,/DEV/XXX interface
Android does not use the OSS driver directly, it can implement the hardware abstraction layer of Android audio part based on OSS.
ALSA Audio Driver
A more convenient audio driver than OSS, ALSA also provides a library of functions in addition to the original interface such as the original IOCTL of the OSS. To simplify the application;
It is recommended that you use the ALSA library interface for user space instead of directly manipulating the ALSA driver.
Instead of using the ALSA driver directly in Android, the Android–>audio hardware abstraction Layer –>alsa Library –>alsa Drive
MTD Drive
Memory technology device, commonly used in Linux flash drivers, including character devices (/DEV/MTDX) and block devices (/dev/block/mtdblockx
MTD drivers are not typically called directly in user space. Instead, it is used to build the file system. User space only needs to use the file system to
Bluetooth driver
Two parts: Bluetooth protocol + bluetooth controller driver.
Bluetooth protocol part: Contains HCI interface, SCO module. L2CAP module. BNEP modules, etc.
Bluetooth Controller Driver section: Provides drivers for Bluetooth devices based on the Sdio/uart/usb interface
WLAN Driver
User space is controlled using the standard socket interface
WiFi drivers are generally compiled into module mode in Android. Loading and unloading via the application settings switch
Android System Development Note 4-underlying libraries and programs
The libraries and programs implemented in this layer are the Android base system, which mainly includes:
- Standard C + + library Bionic
- C Tool Library Libcutils
- C + + Tool Library Libutils
- Init process
- Shell
Bionic-c/c++ Library
Located in the Bionic folder
Bionic light-weight for embedded systems to provide a C + + standard library, support the standard C + + library functions;
Other. Bionic adds some unique features to Android. Example log underlying support, property system (provides global variables within the scope of the system)
"Android System Development" notes