第4课第3节_Android灯光系统_编写HAL_lights.c
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第4课第3节_Android灯光系统_编写HAL_lights.c相关的知识,希望对你有一定的参考价值。
JNI文件:com_android_server_LedService.cpp
注册本地方法,会加载HAL文件:
3. 编写android灯光系统的hal程序
Java: frameworks/base/services/core/java/com/android/server/lights/LightsService.java
JNI: frameworks/base/services/core/jni/com_android_server_lights_LightsService.cpp
Hal: lights.c
默认配色:frameworks/base/core/res/res/values/config.xml
电池灯:frameworks/base/services/core/java/com/android/server/BatteryService.java
通知灯:frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java
怎么写LIGHTS HAL
a. 实现一个名为HMI的hw_module_t结构体
b. 实现一个open函数, 它会根据name返回一个light_device_t结构体
c. 实现多个light_device_t结构体,每一个对应一个DEVICE
light_device_t结构体里第1个成员是hw_device_t结构体, 紧接着一个set_light函数
HAL: lights.c
把新文件上传到服务器, 所在目录: hardware/libhardware/modules/lights/led_hal.c hardware/libhardware/modules/lights/Android.mk
Android.mk内容如下: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := lights.tiny4412 LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_C_INCLUDES := hardware/libhardware LOCAL_SRC_FILES := lights.c LOCAL_SHARED_LIBRARIES := liblog LOCAL_MODULE_TAGS := eng include $(BUILD_SHARED_LIBRARY) 修改 vi vendor/friendly-arm/tiny4412/device-tiny4412.mk ifeq ($(BOARD_USES_PWMLIGHTS),false) #PRODUCT_COPY_FILES += # $(VENDOR_PATH)/proprietary/lights.tiny4412.so:system/lib/hw/lights.tiny4412.so endif
编译:
执行mmm命令之前先执行这几个命令:
$ mmm hardware/libhardware/modules/lights $ make snod $ ./gen-img.sh
用这个命令确保我们提供的lights.c已经编进system.img: diff vendor/friendly-arm/tiny4412/proprietary/lights.tiny4412.so out/target/product/tiny4412/system/lib/hw/lights.tiny4412.so
没有修改代码进行强制编译 -B
内核也需要修改:修改权限 1. drivers/leds/led-class.c: 0644 改为 0666 static struct device_attribute led_class_attrs[] = { __ATTR(brightness, 0666, led_brightness_show, led_brightness_store), __ATTR(max_brightness, 0444, led_max_brightness_show, NULL), #ifdef CONFIG_LEDS_TRIGGERS __ATTR(trigger, 0666, led_trigger_show, led_trigger_store), #endif __ATTR_NULL, }; 2. drivers/leds/ledtrig-timer.c: 0644 改为 0666 #if defined(CONFIG_MACH_IPCAM) static DEVICE_ATTR(delay_on, 0666, led_delay_on_show, led_delay_on_store); static DEVICE_ATTR(delay_off, 0666, led_delay_off_show, led_delay_off_store); #else static DEVICE_ATTR(delay_on, 0666, led_delay_on_show, led_delay_on_store); static DEVICE_ATTR(delay_off, 0666, led_delay_off_show, led_delay_off_store); #endif make zImage 用这个命令确保我们提供的lights.c已经编进system.img: diff vendor/friendly-arm/tiny4412/proprietary/lights.tiny4412.so out/target/product/tiny4412/system/lib/hw/lights.tiny4412.so logcat lights:V *:S
以上是关于第4课第3节_Android灯光系统_编写HAL_lights.c的主要内容,如果未能解决你的问题,请参考以下文章
8.3 Android灯光系统_编写HAL_lights.c
8.3 Android灯光系统_编写HAL_lights.c