1. frameworks/base/services/jni/com_android_server_LightsService.cpp, it is interface for java
- static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
- int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode)
- {
- Devices* devices = (Devices*)ptr;
- light_state_t state;
- if (light < 0 || light >= LIGHT_COUNT || devices->lights[light] == NULL) {
- return ;
- }
- memset(&state, 0, sizeof(light_state_t));
- state.color = colorARGB;
- state.flashMode = flashMode;
- state.flashOnMS = onMS;
- state.flashOffMS = offMS;
- state.brightnessMode = brightnessMode;
- {
- ALOGD_IF_SLOW(50, "Excessive delay setting light");
- devices->lights[light]->set_light(devices->lights[light], &state);
- }
- }
2. hardware/qcom/display/liblight/lights.c
- static int open_lights(const struct hw_module_t* module, char const* name,
- struct hw_device_t** device)
- {
- int (*set_light)(struct light_device_t* dev,
- struct light_state_t const* state);
- if (0 == strcmp(LIGHT_ID_BACKLIGHT, name))
- set_light = set_light_backlight; // backlight
- else if (0 == strcmp(LIGHT_ID_BATTERY, name))
- set_light = set_light_battery; // battery charge
- else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name))
- set_light = set_light_notifications; // notifications for missed calls ,messages and so on.
- else if (0 == strcmp(LIGHT_ID_ATTENTION, name))
- set_light = set_light_attention; // not sure
- else
- return -EINVAL;
- pthread_once(&g_init, init_globals);
- struct light_device_t *dev = malloc(sizeof(struct light_device_t));
- memset(dev, 0, sizeof(*dev));
- dev->common.tag = HARDWARE_DEVICE_TAG;
- dev->common.version = 0;
- dev->common.module = (struct hw_module_t*)module;
- dev->common.close = (int (*)(struct hw_device_t*))close_lights;
- dev->set_light = set_light;
- *device = (struct hw_device_t*)dev;
- return 0;
- }
- static struct hw_module_methods_t lights_module_methods = {
- .open = open_lights,
- };
- /*
- * The lights Module
- */
- struct hw_module_t HAL_MODULE_INFO_SYM = {
- .tag = HARDWARE_MODULE_TAG,
- .version_major = 1,
- .version_minor = 0,
- .id = LIGHTS_HARDWARE_MODULE_ID,
- .name = "lights Module",
- .author = "Google, Inc.",
- .methods = &lights_module_methods,
- };
Charging status precedes the status of missed call.
Compile modules:
- # . ./build/envsetup.sh
- # lunch num
- # make lights.msm8960