新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > Android按鍵燈流程分析

Android按鍵燈流程分析

作者: 時間:2016-10-29 來源:網(wǎng)絡 收藏

調(diào)用代碼為:

本文引用地址:http://m.butianyuan.cn/article/201610/306010.htm

alpsframeworksbaseservicesjavacomAndroidserverLightsService.java

使用方法:

private LightsService.Light mButtonLight;

mButtonLight = mLightsService.getLight(LightsService.LIGHT_ID_BUTTONS);

mButtonLight.setBrightness(screenBrightness);

mButtonLight.turnOff();

本地代碼在:

alpsframeworksbaseservicesjnicom__server_LightsService.cpp

接口關聯(lián)使用:

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__server_LightsService(JNIEnv *env)

{

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

method_table, NELEM(method_table));

}

register_android_server_LightsService函數(shù)在alpsframeworksbaseservicesjnionload.cpp里面注冊

本地c代碼在:

alpsmediatekhardwareliblightslights.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);來調(diào)用真正的代碼

如果有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 執(zhí)行的意思為:輸出0,作為/sys/class/leds/button-backlight/brightness的輸入傳入。

如此便會打開brightness設備,并執(zhí)行write將0帶入執(zhí)行。



關鍵詞: android 按鍵

評論


相關推薦

技術專區(qū)

關閉