Copyright (c) ghd214.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. A copy of the license is included in the section entitled "GNU Free Documentation License".
Revision History |
---|
Revision 0.1 | 01.09.2011 | ghd214 |
created |
| | |
这个是Jollen的hal 层架构的demo,分析如下:
.
|-- Android.mk
|-- apps
| |-- Android.mk
| |-- LedClient
| | |-- AndroidManifest.xml
| | |-- Android.mk
| | `-- src
| | `-- com
| | `-- mokoid
| | `-- LedClient
| | `-- LedClient.java
| `-- LedTest
| |-- AndroidManifest.xml
| |-- Android.mk
| `-- src
| `-- com
| `-- mokoid
| `-- LedTest
| |-- LedSystemServer.java
| `-- LedTest.java
|-- frameworks
| |-- Android.mk
| `-- base
| |-- Android.mk
| |-- core
| | `-- java
| | `-- mokoid
| | `-- hardware
| | |-- ILedService.aidl
| | `-- LedManager.java
| `-- service
| |-- Android.mk
| |-- com.mokoid.server.xml
| |-- java
| | `-- com
| | `-- mokoid
| | `-- server
| | `-- LedService.java
| `-- jni
| |-- Android.mk
| `-- com_mokoid_server_LedService.cpp
|-- hardware
| |-- Android.mk
| |-- libled
| | |-- Android.mk
| | `-- libled.c
| `-- modules
| |-- Android.mk
| |-- include
| | `-- mokoid
| | `-- led.h
| `-- led
| |-- Android.mk
| `-- led.c
|-- README.txt
`-- tags
整个架构中,应该分为5层,如下,
1 层为应用层,本例子主要通过LedService对象实现操作,
(我想也可以通过LedManager实现对下层的操作)
*****************111111*******
***********
|-- Android.mk
|-- apps
| |-- Android.mk
| |-- LedClient
| | |-- AndroidManifest.xml
| | |-- Android.mk
| | `-- src
| | `-- com
| | `-- mokoid
| | `-- LedClient
| | `-- LedClient.java
| `-- LedTest
| |-- AndroidManifest.xml
| |-- Android.mk
| `-- src
| `-- com
| `-- mokoid
| `-- LedTest
| |-- LedSystemServer.java
| `-- LedTest.java
|
*****************111111*******
***********
2,3层主要是jni的实现,
其中2层是jni的Java层实现,主要通过载入动态库/
system/lib/libmokoid_runtime.
so,实现对C++ 层的调用
*****************222222*******
***********
|-- frameworks
| |-- Android.mk
| `-- base
| |-- Android.mk
| |-- core
| | `-- java
| | `-- mokoid
| | `-- hardware
| | |-- ILedService.aidl
| | `-- LedManager.java
| `-- service
| |-- Android.mk
| |-- com.mokoid.server.xml
| |-- java
| | `-- com
| | `-- mokoid
| | `-- server
| | `-- LedService.java
*****************222222*******
***********
3层为jni的c++实现,生成动态库/system/lib/
libmokoid_runtime.so供上层调用,
对下层主要通过hal 层hw_get_module
得到module 和 control 对象并调用其方法,对上层通过registerMethods 方法注册方法,供上层调用。
*****************333333*******
***********
| `-- jni
| |-- Android.mk
| `-- com_mokoid_server_LedService.
cpp
*****************333333*******
***********
4,5层可以通称为hal 层的实现,
4层主要实现对设备节点的直接操作,如设备节点 /dev/led
*****************444444*******
***********
|-- hardware
| |-- Android.mk
| |-- libled
| | |-- Android.mk
| | `-- libled.c
*****************444444*******
***********
5层主要是对4层的hal 封装
*****************555555*******
***********
| `-- modules
| |-- Android.mk
| |-- include
| | `-- mokoid
| | `-- led.h
| `-- led
| |-- Android.mk
| `-- led.c
*****************555555*******
***********
|-- README.txt
`-- tags
通过上面的大概分析,其实可以分为3层,应用层,JNI 层,HAL层,当然在往下就是驱动了。