1. 上层应用APP
1)源文件:
packages/experimental/Freg/
├── AndroidManifest.xml
├── Android.mk
├── res
│ ├── drawable
│ │ └── icon.png
│ ├── layout
│ │ └── main.xml
│ └── values
│ └── strings.xml
└── src
└── shy
└── luo
└── freg
└── Freg.java
2)编译方式:
mmm ./packages/experimental/Freg/
3)目标文件:
out/target/product/generic/system/app/Freg.apk
4)调用方式:
fregService.getVal()
fregService.setVal(val)
2. 硬件访问服务接口
1)源文件:
frameworks/base/core/java/android/os/IFregService.aidl
frameworks/base/Android.mk
编译方式:
mmm ./frameworks/base/
目标文件:
out/target/product/generic/system/framework/framework.jar
frameworks/base/services/java/com/android/server/FregService.java
编译方式:
mmm ./frameworks/base/services/java/
目标文件:
out/target/product/generic/system/framework/services.jar
2)调用方式:
FregService() -> mPtr = init_native()
setVal() -> setVal_native(mPtr, val)
getVal() -> getVal_native(mPtr)
3. 硬件访问服务的JNI方法
1)源文件:
frameworks/base/services/jni/com_android_server_FregService.cpp
frameworks/base/services/jni/onload.cpp
frameworks/base/services/jni/Android.mk
2)编译方法:
mmm ./frameworks/base/services/jni/
3)目标文件:
out/target/product/generic/system/lib/libandroid_servers.so
4)调用方法:
device->set_val(device, val)
device->get_val(device, &val)
freg_device_open(&(module->common), &device)
4. 硬件抽象层模块接口
1)源文件:
hardware/libhardware/include/hardware/freg.h
hardware/libhardware/modules/freg/
├── Android.mk
└── freg.cpp
2)编译方式:
mmm ./hardware/libhardware/modules/freg/
3) 目标文件:
out/target/product/generic/system/lib/hw/freg.default.so
4)调用方式:
open
read
write
5. Linux driver驱动模块
1)源文件:
kernel/goldfish/drivers/Makefile
kernel/goldfish/drivers/freg/
├── freg.c
├── freg.h
├── Kconfig
└── Makefile
2) 编译方式:
make
3) 目标文件:
kernel/goldfish/arch/arm/boot/zImage