Chinaunix首页 | 论坛 | 博客
  • 博客访问: 617466
  • 博文数量: 204
  • 博客积分: 5172
  • 博客等级: 上校
  • 技术积分: 2092
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-08 21:48
个人简介

一个毫无毅力之人的自勉

文章分类

全部博文(204)

文章存档

2014年(1)

2013年(54)

2012年(50)

2011年(94)

2010年(3)

2009年(3)

分类:

2012-06-21 09:15:52


1.framework/base/services/java/com/android/server/lightsService.java


点击(此处)折叠或打开

  1.     static final int LIGHT_ID_BACKLIGHT = 0;
  2.     static final int LIGHT_ID_KEYBOARD = 1;
  3.     static final int LIGHT_ID_BUTTONS = 2;
  4.     static final int LIGHT_ID_BATTERY = 3;
  5.     static final int LIGHT_ID_NOTIFICATIONS = 4;
  6.     static final int LIGHT_ID_ATTENTION = 5;
  7.     static final int LIGHT_ID_BLUETOOTH = 6;
  8.     static final int LIGHT_ID_WIFI = 7;    //暂时未使用
  9.     static final int LIGHT_ID_COUNT = 8;   //暂时未使用

  10.     static final int LIGHT_FLASH_NONE = 0;
  11.     static final int LIGHT_FLASH_TIMED = 1;
  12.     static final int LIGHT_FLASH_HARDWARE = 2;


点击(此处)折叠或打开

  1.     private static native int init_native();
  2.     private static native void finalize_native(int ptr);
  3.     private static native void setLight_native(int ptr, int light, int color, int mode,
  4.             int onMS, int offMS, int brightnessMode);

2.framework/base/service/jni/com_android_server_LightsService.cpp

点击(此处)折叠或打开

  1. static JNINativeMethod method_table[] = {
  2.     { "init_native", "()I", (void*)init_native },
  3.     { "finalize_native", "(I)V", (void*)finalize_native },
  4.     { "setLight_native", "(IIIIIII)V", (void*)setLight_native },
  5. };


点击(此处)折叠或打开

  1. static jint init_native(JNIEnv *env, jobject clazz)
  2. {
  3.     int err;
  4.     hw_module_t* module;
  5.     Devices* devices;
  6.     
  7.     devices = (Devices*)malloc(sizeof(Devices));

  8.     err = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
  9.     if (err == 0) {
  10.         devices->lights[LIGHT_INDEX_BACKLIGHT]
  11.                 = get_device(module, LIGHT_ID_BACKLIGHT);
  12.         devices->lights[LIGHT_INDEX_KEYBOARD]
  13.                 = get_device(module, LIGHT_ID_KEYBOARD);
  14.         devices->lights[LIGHT_INDEX_BUTTONS]
  15.                 = get_device(module, LIGHT_ID_BUTTONS);
  16.         devices->lights[LIGHT_INDEX_BATTERY]
  17.                 = get_device(module, LIGHT_ID_BATTERY);
  18.         devices->lights[LIGHT_INDEX_NOTIFICATIONS]
  19.                 = get_device(module, LIGHT_ID_NOTIFICATIONS);
  20.         devices->lights[LIGHT_INDEX_ATTENTION]
  21.                 = get_device(module, LIGHT_ID_ATTENTION);
  22.         devices->lights[LIGHT_INDEX_BLUETOOTH]
  23.                 = get_device(module, LIGHT_ID_BLUETOOTH);
  24.         devices->lights[LIGHT_INDEX_WIFI]
  25.                 = get_device(module, LIGHT_ID_WIFI);
  26.     } else {
  27.         memset(devices, 0, sizeof(Devices));
  28.     }

  29.     return (jint)devices;
  30. }



点击(此处)折叠或打开

  1. static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
  2.         int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode)
  3. {
  4.     Devices* devices = (Devices*)ptr;
  5.     light_state_t state;

  6.     if (light < 0 || light >= LIGHT_COUNT || devices->lights[light] == NULL) {
  7.         return ;
  8.     }

  9.     memset(&state, 0, sizeof(light_state_t));
  10.     state.color = colorARGB;
  11.     state.flashMode = flashMode;
  12.     state.flashOnMS = onMS;
  13.     state.flashOffMS = offMS;
  14.     state.brightnessMode = brightnessMode;

  15.     devices->lights[light]->set_light(devices->lights[light], &state);
  16. }



点击(此处)折叠或打开

  1. static void finalize_native(JNIEnv *env, jobject clazz, int ptr)
  2. {
  3.     Devices* devices = (Devices*)ptr;
  4.     if (devices == NULL) {
  5.         return;
  6.     }

  7.     free(devices);
  8. }


阅读(1657) | 评论(0) | 转发(0) |
0

上一篇:camera

下一篇:ssh tunnel

给主人留下些什么吧!~~