您的位置 首页 资料

Android按键灯流程剖析

调用代码为:alps\frameworks\base\services\java\com\Android\server\LightsService.java使用方法:private LightsSer

调用代码为:

alps\frameworks\base\services\java\com\Android\server\LightsService.java

运用方法:

private LightsService.Light mButtonLight;

mButtonLight = mLightsService.getLight(LightsService.LIGHT_ID_BUTTONS);

mButtonLight.setBrightness(screenBrightness);

mButtonLight.turnOff();

本地代码在:

alps\frameworks\base\services\jni\com_android_server_LightsService.cpp

接口相关运用:

static JNINativeMethod method_table[] = {

{ init_native, ()I, (void*)init_native },

{ finalize_native, (I)V, (void*)finalize_native },

{ setLight_native, (IIIIIII)V, (void*)setLight_native },

};

int register_android_server_LightsService(JNIEnv *env)

{

return jniRegisterNativeMethods(env, com/android/server/LightsService,

method_table, NELEM(method_table));

}

register_android_server_LightsService函数在alps\frameworks\base\services\jni\onload.cpp里边注册

本地c代码在:

alps\mediatek\hardware\liblights\lights.c里边open_lights里边

static int

set_light_buttons(struct light_device_t* dev,

struct light_state_t const* state)

{

int err = 0;

int on = is_lit(state);

pthread_mutex_lock(g_lock);

g_buttons = on;

err = write_int(BUTTON_FILE, on?255:0);

pthread_mutex_unlock(g_lock);

return err;

}

com_android_server_LightsService.cp里边运用 devices->lights[light]->set_light(devices->lights[light], state);来调用真实的代码

如果有root机子,能够如下测验:

echo 0 > /sys/class/leds/button-backlight/brightness 关按键

echo 1 > /sys/class/leds/button-backlight/brightness 开按键

echo 0 > /sys/class/leds/button-backlight/brightness 履行的意思为:输出0,作为/sys/class/leds/button-backlight/brightness的输入传入。

如此便会翻开brightness设备,并履行write将0带入履行。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/282258.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部