led_高通7x8x

1645阅读 0评论2012-06-21 chengyake
分类:


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. }


上一篇:camera
下一篇:ssh tunnel