1. packages/apps/Settings/src/com/Android/settings/BrightnessPreference.java
2.frameworks/base/core/java/Android/os/IPowerManager.aidl.java
--> // sets the brightness of the backlights (screen, keyboard, button) 0-255
void setBacklightBrightness(int brightness)
3.frameworks/base/core/java/Android/os/PowerManager.java
public void setBacklightBrightness(int brightness)
{
try {
mService.setBacklightBrightness(brightness);
} catch (RemoteException e) {
}
}
4.frameworks/base/services/java/com/Android/server/PowerManagerService.java
-- >public void setBacklightBrightness(int brightness) {
5.frameworks/base/services/java/com/android/server/LightsService.java
public void setBrightness(int brightness) {
setBrightness(brightness, BRIGHTNESS_MODE_USER);
}
public void setBrightness(int brightness, int brightnessMode) {
synchronized (this) {
int color = brightness & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
}
}
6./frameworks/base/services/jni/com_android_server_LightsService.cpp
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;
devices->lights[light]->set_light(devices->lights[light], &state);
}
7. devices/vendor/board/liblights.c
set_light_backlight(struct light_device_t* dev,
struct light_state_t const* state)
{
int err = 0;
int brightness = rgb_to_brightness(state);
int fd;
char buf[1]={0};
pthread_mutex_lock(&g_lock);
fd = open(LCD_FILE, O_RDONLY);
err=read(fd, &buf, 1);
close(fd);
if(buf[0] == '0' && brightness)
usleep(200000);
err = write_int(LCD_FILE, brightness);
pthread_mutex_unlock(&g_lock);
return err;
}
char const*const LCD_FILE
= "/sys/class/leds/lcd-backlight/brightness";
8. kernel/driver/leds
ex: kernel/driver/leds/xxxx-pwm.c
沒有留言:
張貼留言