Android system)

Source: Internet
Author: User
Tags vector font

ThisArticleVery good. I have a detailed introduction to the Android system structure.

Link: http://blog.csdn.net/yuanyou/archive/2009/05/18/4194526.aspx

 

Android is a platform developed by Google for mobile phones.Code, Most of its applicationsProgramIt is developed in Java. After all, it is a commercial product, and it is a matter of course. For Embedded Linux developers, we can learn their strengths from them. It is also a development direction and trend in the future.

Let's take a look at the architecture of Android. The following is a public Android architecture diagram.

 

Android adopts a hierarchical architecture like its operating system. From the structural diagram, Android is divided into four layers: application layer, application framework layer, system Runtime Library layer, and Linux core layer. Blue represents the Java program. The yellow code is the virtual machine that runs the Java program. The green part is the library written in C/C ++ and the red code kernel (Linux kernel + drvier)

 

1. Applications

Android is released together with a series of core application packages, including email clients, SMS Short Message programs, calendars, maps, browsers, and contact management programs. All applications are written in Java.

 

2. Application Framework

Developers can also fully access the API framework used by core applications. The architecture design of this application simplifies Component reuse; any application can publish its functional blocks, and any other application can use the released functional blocks (but the security restrictions of the framework must be followed ). Similarly, this application reuse mechanism allows you to easily replace program components.

A series of services and systems are hidden behind each application, including;

* Rich and scalable views can be used to build applications, including lists, grids, and text boxes ), button (buttons), or even an embedded web browser.
* Content providers allow applications to access data of another application (such as the contact database) or share their own data.
* Resource manager provides access to non-code resources, such as local strings, images, and layout files ).
* Notification Manager allows applications to display custom prompts in the status bar.
* Activity manager is used to manage the application lifecycle and provides common navigation rollback functions.

For more details and how to write an application from scratch, see how to write an Android Application.

 

3. System Runtime Library

1) Library

Android contains some C/C ++ libraries that can be used by different components in the Android system. They provide services to developers through the Android Application Framework. The following are some core databases:

* bionic system C library-a standard C system function library (libc) inherited from BSD, which is specially customized for Embedded Linux-based devices.
* media library-Based on packetvideo opencore. This Library supports multiple common audio and video formats for playback and recording, and supports static image files. The encoding formats include MPEG4, H.264, MP3, AAC, Amr, JPG, and PNG.
* surface Manager-manages the display subsystem and provides seamless integration of 2D and 3D layers for multiple applications. This part of the Code
* WebKit, libwebcore-is used by the latest web browser engine and supports the android browser and an embedded Web View. The engine behind the well-known Apple Safari is WebKit
* SGL-underlying 2D graphics engine
* 3D libraries-implemented based on OpenGL ES 1.0 APIs; this library can use hardware 3D acceleration (if available) or highly optimized 3D soft acceleration.
* FreeType-bitmap and vector font display.
* SQLite-a lightweight relational database engine that is available to all applications and has powerful functionality.

* What is not shown above is the hardware abstraction layer. In fact, Android does not mean that all device drivers are placed in the Linux kernel, but are implemented in the userspace. The main reason for this is the GPL protocol, which is followed by Linux, this means that any modifications to the Linux kernel must be released.Source code. Now, this can be avoided without having to publish its source code. After all, it is used to make money. In the Linux kernel, you can open a backdoor for these userspace driver codes, so that hardware that is not directly controlled by the userspace driver can be accessed. You only need to publish the backdoor code. Generally, to port android to other hardware for running, you only need to implement this part of code. Including: display drive, sound, camera, GPS, GSM, etc.

 

2) Android Runtime Library

Android includes a core library that provides JavaProgramming LanguageMost features of the core library.

Every android application runs in its own process and has an independent Dalvik Virtual Machine instance. Dalvik is designed as a device to efficiently run multiple virtual systems at the same time. Dalvik executable files executed by the Dalvik Virtual Machine (. Dex), which are optimized for small memory usage. At the same time, the virtual machine is register-based. All classes are compiled by the Java compiler, and then converted to the. Dex format using the "dx" tool in the SDK is executed by the virtual machine.

The Dalvik virtual machine depends on some features of the Linux kernel, such as the thread mechanism and the underlying memory management mechanism.

 

4. Linux Kernel

Android core system services depend on the Linux 2.6 kernel, such as security, memory management, process management, network protocol stack and driver model. The Linux kernel is also an abstraction layer between the hardware and software stacks. In addition, some modifications have been made, mainly involving two parts:

1 ). binder (IPC): provides effective inter-process communication. Although the Linux kernel itself provides these functions, many Android services require this function, for some reason, it implements its own set.

2). Power Management: mainly for power saving. After all, it is a handheld device. Low Power Consumption is our pursuit.

 

 

 

Finally, let's talk about the language used by Android. Its Application Development adopts the Java language. The Java we call generally contains three parts:

1) Java language: Its syntax. It is a program that writes code.

2 ). java Virtual Machine: To achieve the principle that a compilation can run everywhere, Java does not generate the target machine language after the compilation connection, but uses the Java bytecode shared instruction, in this case, a virtual machine is required to execute the change command.

3). Library: provides some common libraries like the common C language.

The combination of the two is Java Runtime Environment.

 

The Virtual Machine Used by Android is called Dalvik. It was originally not designed for Java and cannot run the Java bytecode command. Instead, it runs Dalvik executable, DX for short. Android provides the DX tool to convert Java bytecode to DX.

 

 

Android source code structure:

Android provided by Google contains the original Android target machine code, host compilation tools, and simulation environment. After the code package is decompressed, the first-level directories and files are as follows:
.
| -- Makefile (Global makefile)
| -- Bionic)
| -- Bootloader)
| -- Build (the content in the build directory is not the code used by the target, but the scripts and tools required for compilation and configuration)
| -- Dalvik (Java Virtual Machine)
| -- Development (templates and tools required for Program Development)
| -- External (some libraries used by the target machine)
| -- Frameworks (framework layer of the Application)
| -- Hardware (hardware-related Library)
| -- Kernel (source code of linux2.6)
| -- Packages (various Android applications)
| -- Prebuilt (preset scripts compiled by android on various platforms)
| -- Recovery (related to the recovery function of the target)
'-- System (some underlying libraries of Android)

The bionic directory is displayed as follows:
Bionic/
| -- Android. mk
| -- Libc
| -- Libdl
| -- Libm
| -- Libstdc ++
| -- Libthread_db
'-- Linker

two levels of bootloader Directory:
bootloader/
'-- legacy
| -- android. MK
| -- readme
| -- arch_armv6
| -- arch_msm7k
| -- fastboot_protocol.txt
| -- include
| -- libboot
| -- libc
| -- nandwrite
'-- usbloader

The build directory is displayed in the following directory:
Build/
| -- Buildspec. mk. Default
| -- Cleanspec. mk
| -- Core (various files ending with MK, which are makefiles required for compilation)
| -- Envsetup. Sh
| -- Libs
| -- Target (contains two directories: Board and product, which are the files required by the target)
'-- Tools (tools required by the host during compilation, which must be compiled and generated)

The makefile in core is the real makefile required for the entire android compilation. It is referenced by the makefile in the top-level directory.
Envsetup. Sh is a script used to set the environment when running with a simulator.
The Dalvik directory is used to provide the Java Virtual Machine (JVM), the Foundation for running Android Java applications.
The Development Directory is displayed in the following directory:
Development
| -- Apps (Android Application Template)
| -- Build (compile Script Template)
| -- Cmds
| -- Data
| -- Docs
| -- Emulator (simulation related)
| -- Host (including some tools on the Windows platform)
| -- Ide
| -- PDK
| -- Samples (some sample programs)
| -- Simulator (mostly some tools on the target machine)
'-- Tools

In the emulator directory, qemud is the background program running on the target machine during qemu simulation. skins are the mobile phone interface during simulation.
samples contains many simple Android projects, which provide great convenience for developers to learn and develop Android programs and can be used as templates.
the external directory is displayed in the following directory:
external/
| -- AES
| -- APACHE-HTTP
| -- bluez
| -- clearsilver
| -- keystore
| -- dhcpcd
| -- dropbear
| -- elfcopy
| -- elfutils
| -- Emma
| -- ESD
| -- expat
| -- fdlibm
| -- FreeType
| -- gdata
| -- giflib
| -- googleclient
| -- icu4c
| -- iptables
| -- jdiff
| -- jhead
| -- JPEG
| -- libffi
| -- libpcap
| -- libpng
| -- libxml2
| -- Netcat
| -- netperf
| -- Neven
| -- opencore
| -- OpenSSL
| -- oprofile
| -- ping
| -- PPP
| -- protobuf
| -- qemu
| -- safe-IOP
| -- skia
| -- sonivox
| -- SQLite
| -- SREC
| -- strace
| -- tagsoup
| -- tcpdump
| -- tinyxml
| -- tremor
| -- WebKit
| -- wpa_supplicant
| -- yaffs2
'-- zlib

In external, each directory represents a module in the android target system, which may contain one or more libraries. Where:
Opencore is PV (packetvideo), which is the core of the android multimedia framework.
WebKit is the core of the android web browser.
SQLite is the core of the android database system.
OpenSSL is a Secure Socket Layer, a network protocol layer, used to provide security support for data communication.
The frameworks directory is displayed in the following directory:
Frameworks/
| -- Base
| -- OPT
'-- Policies

Frameworks is the framework of Android applications.
Hardware is a hardware-related library.
Kernel is the source code of linux2.6

The packages directory is displayed in the following two levels:
Packages/
| -- Apps
| -- Alarmclock
| -- Browser
| -- Calculator
| -- Calendar
| -- Camera
| -- Contacts
| -- Email
| -- Googlesearch
| -- Htmlviewer
| -- Im
| -- Launcher
| -- MMS
| -- Music
| -- Packageinstaller
| -- Phone
| -- Settings
| -- Soundrecorder
| -- STK
| -- Sync
| -- Updater
| '-- Voicedialer
'-- Providers
| -- Calendarprovider
| -- Contactsprovider
| -- Downloadprovider
| -- Drmprovider
| -- Googlecontactsprovider
| -- Googlesubscribedfeedsprovider
| -- Improvider
| -- Mediaprovider
'-- Telephonyprovider

Packages contains two directories, among which apps are various Android applications, and providers are some content providers (a data source in Android ).
The contents of the two directories in packages are mostly programs written in Java, and the hierarchical structure of each folder is similar.
The prebuilt directory is displayed in the following directory:
Prebuilt/
| -- Android. mk
| -- Android-arm
| -- Common
| -- Darwin-x86
| -- Linux-x86
'-- Windows

The two levels of system directory expansion are as follows:
System/
| -- Bluetooth
| -- Bluedroid
| '-- Brfpatch
| -- Core
| -- Android. mk
| -- Readme
| -- ADB
| -- Cpio
| -- Debugadh
| -- Fastboot
| -- Include (header files of each library interface)
| -- Init
| -- Libctest
| -- Libcutils
| -- Liblog
| -- Libmincrypt
| -- Libnetutils
| -- Libpixelflinger
| -- Libzipfile
| -- Logcat
| -- Logwrapper
| -- Mkbootimg
| -- Mountd
| -- Netcfg
| -- Rootdir
| -- Sh
| '-- Toolbox
| -- Extras
| -- Android. mk
| -- Latencytop
| -- Libpagemap
| -- Librank
| -- Procmem
| -- Procrank
| -- Showmap
| -- Showslab
| -- Sound
| -- Su
| -- Tests
| '-- Timeinfo
'-- WLAN
'-- Ti

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.