Nineth Chapter
This chapter mainly studies HAL. The hardware abstraction Layer of Android is the encapsulation of the Linux kernel driver, providing the interface upwards, shielding the implementation details of the lower level. The hardware support is divided into two layers, one layer in the user space, one layer in the kernel space, where the hardware abstraction layer runs in the user space, and the Linux kernel driver runs in the kernel space. added HAL for LED driver
Step 1 , write Linux Drivers
" writing linux drivers "is nonsense from the show, but if you want to add HAL to the Linux driver , and want to protect sensitive data as much as possible. Linux - driven code needs to be as concise as possible to put business logic into hallibrary .
Step 2 : Write the HAL Library
The HAL library is an ordinary Linux Library. so ) file. However, this type of library file has an interface. Implemented by hal_module_info_ SYM variables. the Service Library locates the HAL Library by the ID defined in this interface .
Step 3 : Write the Service Library
Service Libraryis alsoLinux Library. Service Libraryit can be normal.Linux Library, or it can be notThe Library. In this chapter,LEDThe driver example willService libratγand criminalI Librarytogether. In other words,Service Libraryis thatJNI Library.In fact, this step is in addition toCICimplementation of the item *. solibrary file, you should also include aJavathe service management classes written(ServiceManager). ServiceManageris calledService Library. andAPKprogram will callServiceManagerClass meter AccessService Library.
"Android Deep Exploration" Vol. 1 nineth note 1314 Wang Ning