欢迎来到天天文库
浏览记录
ID:40542427
大小:20.85 KB
页数:6页
时间:2019-08-04
《android平台开发之框架层》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、框架层(framework) 这里主要实现两部分(1:为AndroidHAL编写JNI方法,以便使得上层的APP能够使用下层提供的硬件服务(2:在Android系统的框架层提供Java接口的硬件服务1,在frameworks/base/services/jni中新建com_android_server_swtled.cpp点击(此处)折叠或打开1.#defineLOG_TAG"SwtledService"2.#include"jni.h"3.#include"JNIHelp.h"4.#include"android_runtime/
2、AndroidRuntime.h"5.#include6.#include7.#include8.#include9.#include10.11.12.13.namespaceandroid14.{15. structswtled_device_t*swtled_device=NULL;16.17.18. staticvoidswtled_set_on(JNIEnv*env
3、,jobjectclazz,jintnumber)19. {20. intnum=number;21. LOGI("SwtledJNI:selectlightonis%d",num);22.23. if(!swtled_device)24. {25. LOGI("SwtledJNI:deviceisnotopen.");26. return;27. }28. swtled_device->set_on(
4、swtled_device,num);29. }30.1. staticvoidswtled_set_off(JNIEnv*env,jobjectclazz,jintnumber)2. {3. 4. intnum=number;5. LOGI("SwtledJNI:selectlightoffis%d",num);6.7. if(!swtled_device)8. {9. LOGI("SwtledJNI:deviceisno
5、topen.");10. return;11. }12. swtled_device->set_off(swtled_device,num);13. }14.15. staticinlineintswtled_device_open(hw_module_t*module,swtled_device_t**device)16. {17. returnmodule->methods->open(module,SWTLED_HARDWARE_MODULE_ID
6、,(hw_device_t**)device);18. }19. 20.21. staticjbooleanswtled_init(JNIEnv*env,jclassclazz)22. {23. swtled_module_t*swtledmodule;24. 25. LOGI("SwtledJNI:initializing...");26.27. if(hw_get_module(SWTLED_HARDWARE_MODULE_ID,(conststruc
7、thw_module_t**)&swtledmodule)==0)28. {29. LOGI("SwtledJNI:swtledstubbefound.");30. if(swtled_device_open(&(swtledmodule->common),&swtled_device)==0)31. {32. LOGI("SwtledJNI:swtleddeviceopensuccessful.");33.
8、 return0;34. }35.1. LOGI("SwtledJNI:failedtoopenswtleddevice.");2. retu
此文档下载收益归作者所有