4th lesson 3rd Section _android Lighting System _ Writing HAL_LIGHTS.C

Source: Internet
Author: User

JNI file: Com_android_server_ledservice.cpp

Registering the local method will load the HAL file:


3. Writing the HAL program for the Android lighting system


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

Default color: Frameworks/base/core/res/res/values/config.xml
Battery Light: Frameworks/base/services/core/java/com/android/server/batteryservice.java
Notification Light: Frameworks/base/services/core/java/com/android/server/notification/notificationmanagerservice.java

How to write Lights HAL
A. Implementing a hw_module_t structure called the HMI
B. Implement an open function that returns a light_device_t struct based on name
C. Implement multiple light_device_t structures, each corresponding to a device
The 1th member in the light_device_t structure is the hw_device_t structure, followed by a set_light function

Hal:lights.c

upload the new file to the server directory: Hardware/libhardware/modules/lights/led_hal.chardware/libhardware/modules/ lights/android.mk

The android.mk content is as follows: Local_path:= $ (call my-dir) include $ (clear_vars) Local_module:= Lights.tiny4412local_module_relative_path:= hwlocal_c_includes:= hardware/libhardwarelocal_src _files:= lights.clocal_shared_libraries:= libloglocal_module_tags:= enginclude $ (build_ shared_library) Modify VI vendor/friendly-arm/tiny4412/device-Tiny4412.mkifeq ($ (board_uses_pwmlights), false + = # $ (vendor_path)/proprietary/lights.tiny4412.so:system/lib/hw/ Lights.tiny4412.soendif

Compile:
Execute the following commands before executing the MMM command:





$ mmm hardware/libhardware/modules/lights$ make snod$. /gen-img.sh
Use this command to make sure that the lights.c we provide has been programmed into System.img:diff vendor out/target/product/tiny4412/system/lib/hw/lights.tiny4412.so

No Code modification to force compilation-B

The kernel also needs to be modified: Modify Permissions1. drivers/leds/led-classC0644Switch0666Static structDevice_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:0644Switch0666#ifDefined (CONFIG_MACH_IPCAM)StaticDevice_attr (delay_on,0666, Led_delay_on_show, led_delay_on_store);StaticDevice_attr (Delay_off,0666, Led_delay_off_show, led_delay_off_store);#elseStaticDevice_attr (delay_on,0666, Led_delay_on_show, led_delay_on_store);StaticDevice_attr (Delay_off,0666, Led_delay_off_show, led_delay_off_store);#endifmake zimage Use this command to ensure that the lights.c we provide has been programmed into System.img:diff vendor/friendly-arm/tiny4412/proprietary/lights.tiny4412.so out/target/product/tiny4412/system/lib/hw/Lights.tiny4412.sologcat lights:v*:s

4th lesson 3rd Section _android Lighting System _ Writing HAL_LIGHTS.C

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.