Android system architecture development process (abstract)

1. Hardware abstraction layer HAL of Android system architecture

1.1 Overview of HAL

Android 硬件抽象层,简单来说,就是对Linux内核驱动程序的封装,向上提供接口,屏蔽低层的实现细节.
That is to say, the support for hardware is divided into two layers, one layer is placed in user space (User Space), and the other layer is placed in kernel space (Kernel Space). Among them, the hardware abstraction layer runs in user space, and the Linux kernel driver Programs run in kernel space.
Why do you want to arrange it this way? Is it not feasible to integrate the hardware abstraction layer and the kernel driver together in the kernel space?
From the point of view of technical implementation, it is possible, but from a commercial point of view, putting all the support logic for hardware in the kernel space may damage the interests of manufacturers. We know that the copyright of the Linux kernel source code follows the GNU License, while the copyright of the Android source code follows the Apache License. The former must publish the source code when releasing a product, while the latter does not need to publish the source code. If all the codes supported by the hardware are placed in the Linux driver layer, it means that the source code of the driver should be disclosed when it is released, and the disclosure of the source code means that the relevant parameters and implementation of the hardware are disclosed. In today's fierce competition, this is very harmful to manufacturers. Therefore, Android才会想到把对硬件的支持分成硬件抽象层和内核驱动层,内核驱动层只提供简单的访问硬件逻辑,例如读写硬件寄存器的通道,至于从硬件中读到了什么值或者写了什么值到硬件中的逻辑,都放在硬件抽象层中去了in this way, trade secrets can be hidden. It is precisely because of this layering that Android was kicked out of the Linux kernel mainline code tree. Think about it, the driver program placed in the kernel space of Android has incomplete hardware support. When the Linux kernel is transplanted to other machines, the hardware is completely unusable due to the lack of hardware abstraction layer support. This is why The reason why Android is an open system rather than an open source system .

Putting these debates aside, learning the Android hardware abstraction layer is extremely useful for understanding the entire Android system, because it involves the hardware driver layer, hardware abstraction layer, runtime library, and application framework layer of the Android system from bottom to top. Wait, the following figure illustrates the position of the hardware abstraction layer in the Android system and its relationship with other layers:

Since this is a systematic learning process, the author will divide it into six articles to describe each learning process, including:
( 重点)
1. On Android 内核源代码工程中编写硬件驱动程序. Reference
2. In the Android system 增加C可执行程序来访问硬件驱动程序. Reference
3. On Android 硬件抽象层增加接口模块访问硬件驱动程序. Reference
4. In the Android system 编写JNI方法在应用程序框架层提供Java接口访问硬件. Refer to
5. In the Android system 应用程序框架层增加硬件服务接口. Refer to
6. In the Android system 编写APP通过应用程序框架层访问硬件服务. refer to


insert image description here


The overall architecture is as follows:
insert image description here


1.2 HAL development process

2. Application message mechanism of Android system architecture

2.1 Message processing mechanism (Looper handler) analysis

reference

2.2 Analysis of thread message loop model

reference

Guess you like

Origin blog.csdn.net/weixin_48433164/article/details/127131764