Android 4 Layer Frame

Source: Internet
Author: User

(i) Android system framework Detailed

Android uses a tiered architecture that is divided into four tiers, from high-level to bottom-up to application tiers, application framework tiers, System runtime tiers, and Linux core tiers

1,android Application Layer

The application is written in the Java language running on the virtual machine program, that is the top blue part of the figure, in fact, Google in the first time in the Android system bundled with some core applications, such as e-mail client, SMS short message program, calendar, map, browser, contact management program, Wait a minute.

2, Application framework Layer

This layer is the API framework used to write the core apps that Google publishes, and developers can use these frameworks to develop their own applications, simplifying the architecture of program development, but must adhere to the development principles of their frameworks, with the following components:

Rich and extensible views: can be used to build applications that include lists (lists), grids (grids), text boxes (the text boxes), buttons (buttons), and even web browsers that can be embedded.

Content Providers: It allows one app to access data from another app, such as a contact database, or share their own data

Resource Manager (Resource Manager): Provides access to non-code resources, such as local strings, graphics, and layout files.

Notification Manager (Notification Manager): Apps can display customized prompts in the status bar.

Activity Manager: Used to manage the application lifecycle and provide common navigation fallback functionality.

Window Manager: Manages all of the Windows programs.

Package Manager: Program management within the Android system

Some objects are built into the Android SDK, the most important of which are activities, Intents, services, and content providers four components.

Activities activities
An activity is a user interface. An application can define one or more activities, and each activity can save and restore its own state.

Intents intention
Intent is a mechanism for describing a particular activity, such as "Pick a photo", "Make a call", and other such specific actions. In Android, everything is done through intents, so developers have the opportunity to replace or reuse a large number of components. For example, there is a "send mail" intent, you can activate this intent when your application needs to send a message. Developers can even rewrite a new mail application and register it as an activity to handle the intent instead of the standard mail application. Then other applications can use the new write application to send mail.

Services Service
A Services service is a task that runs in the background and does not interact directly with the user, similar to UNIX daemon. For example, to make a music player, may be activated by another activity, but music is required as a background music playback, then this program can be considered as a service services. Then other activities can be used to manipulate the player. There are many services built into Android that can be easily accessed using the API.

Content providers Contents provider
A content provider contents provider is a set of data that is encapsulated by a custom API that encapsulates read and write operations. Content provider is the best way to share global data between different applications. For example, Google provides a contact's content Provider, which can be used by all applications, including name, address, phone, and all other information.

3, the System Runtime Library layer

When we use the Android app framework, the Android system will support the various components that we use with some C + + libraries, so that they can better serve the developers

Bionic System C Library: C language standard library, the system's lowest level library, C library through the Linux system to invoke.

Multimedia Library (Mediaframeword): Android Multimedia library, based on PacketVideo Opencore, which supports a variety of commonly used audio, video format playback and recording as well as some images, such as: MPEG4, MP3, AAC, AMR, JPG , PNG, and so on.

sgl:2d Graphics Engine Library.

SSL: Provides support for data communication between the TVP/IP protocol and various application layer protocols.

Support for OpenGL ES 1.0:3d effects.

SQLite: relational database.

Webkit:web browser engine.

FreeType: Bitmap (Bitmap) and vector (vectors).

Each Java program runs on top of the Dalvik virtual machine. As with PCs, each Android application has its own process, and the Dalvik virtual machine executes only the ". Dex" executable file. When the Java program is compiled, it will eventually need to be converted to the ". Dex" format through the "DX" tool in the SDK to perform properly on the virtual machine.

The yellow part of the figure is the Dalvik virtual machine, Google officially released the Android SDK at the end of 2007, as an important feature of the Android system, Dalvik virtual machine has also entered the people's vision for the first time. Its efficient use of memory and its high performance on low-speed CPUs are truly impressive. The Android system can simply complete process isolation and thread management. Each Android app will have a standalone Dalvik virtual machine instance on the bottom, and its code can be executed under the virtual machine's interpretation. Many people think that the Dalvik virtual machine is a Java virtual machine, because the Android programming language is precisely the Java language. But this is not accurate, because the Dalvik virtual machine is not implemented according to the specifications of the Java Virtual machine, the two are not compatible, but also two obvious differences: the Java Virtual machine is running Java bytecode, The Dalvik virtual machine runs its proprietary file format, Dex (Dalvik executable). In the Java The Java class in the SE program is compiled into one or more bytecode files (. Class) and then packaged into a jar file, and then the Java Virtual Opportunity obtains the corresponding bytecode from the corresponding class file and jar file; Android applications are programmed in the Java language, but are compiled into a class , a tool (DX) is used to convert all of the class files into a single Dex file and then dalvik the virtual opportunity to read the instructions and data from it.

Dalvik virtual machines are ideal for use on mobile devices and do not require fast CPU speed and large amounts of memory compared to virtual machines running on desktop and server systems. According to Google's calculations, 64M of RAM has allowed the system to function properly. 24M is used for initialization and startup of the underlying system, and 20M is used for high-level start-up services. Of course, with the increase of system service and the expansion of application function, the memory consumed by it is bound to become larger and bigger. To sum up, Dalvik virtual machines have the following main features:

Proprietary DEX file format

Dex is a file format that is dedicated to the Dalvik virtual machine, and why deprecated bytecode files (. class file) and use the new format?

(1) A number of classes are defined in an application, and there are many corresponding class files after compilation, and there is a lot of redundant information in the class file, and the Dex file format consolidates all the class file contents into a single file. This improves the class lookup speed in addition to reducing overall file size and I/O operations.

(2) added support for new opcode.

(3) The file structure is as concise as possible, using equal length instructions, thereby improving the resolution speed.

(4) Maximize the size of the read-only structure, thereby increasing the data sharing across processes.

Dex's Optimizations

The structure of the Dex file is compact, but we still need to further refine the Dex file if we want to further improve the performance of the runtime. The optimization is mainly for the following aspects:

(1) Adjust the byte order (Little_endian) of all fields and align each field in the structure.

(2) Verify all classes in the Dex file.

(3) Optimization of some specific classes, the operation code in the method is optimized.

Register based

Compared with the virtual machine based on the stack implementation, the virtual machine based on the register is inferior in hardware and generality, but it is more efficient in the execution of the code.

An application, a virtual machine instance, a process

Every Android app runs in a single Dalvik virtual machine instance, and each virtual machine instance is a separate process space. The implementation of a virtual machine's threading mechanism, memory allocation and management, and mutexes is dependent on the underlying operating system. All Android apps have threads that correspond to one Linux thread, so virtual machines can rely more on the operating system's thread scheduling and management mechanisms. Different applications run in different process spaces, and applications from different sources run with different Linux users to maximize the security and standalone operation of the application.

4,linux Core Layer

Android's core system services are based on the Linux2.6 kernel, such as security, memory management, process management, network protocol stacks, and driver models, all of which depend on the Linux2.6 kernel. The Linux kernel also acts as an abstraction layer between the hardware and the software stack.

Android is more of a need for some mobile device-related drivers, the main drivers are as follows.

Display Driver: Linux-based framebuffer (frame buffer) driver.

Keyboard driver (KeyBoard Driver): The keyboard driver for the input device.

Flash memory Driver: MTD-based flash driver.

Camera driver (camera Driver): Common Linux-based V4L2 (Video for Linux) drivers.

Audio Driver: A popular Linux sound system driver based on ALSA (Advanced Linux voice Architecture).

Bluetooth driver (bluetooth® Driver): Wireless transmission technology based on IEEE 802.15.1 standard.

WiFi driver (Camera Drive): IEEE 802.11-compliant driver.

Binder IPC Driver: A special driver for Android with a separate device node that provides inter-process communication functionality.

Power Management (Energy management): such as battery power.

Android 4 Layer Frame

Related Article

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.