andoid添加一个休眠唤醒源

上传人:飞*** 文档编号:42567100 上传时间:2018-06-02 格式:DOC 页数:7 大小:78KB
返回 下载 相关 举报
andoid添加一个休眠唤醒源_第1页
第1页 / 共7页
andoid添加一个休眠唤醒源_第2页
第2页 / 共7页
andoid添加一个休眠唤醒源_第3页
第3页 / 共7页
andoid添加一个休眠唤醒源_第4页
第4页 / 共7页
andoid添加一个休眠唤醒源_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《andoid添加一个休眠唤醒源》由会员分享,可在线阅读,更多相关《andoid添加一个休眠唤醒源(7页珍藏版)》请在金锄头文库上搜索。

1、最近需要做个唤醒功能,当按键的时候 android 系统唤醒并点亮屏,在长按键中,系统不 能在进入睡眠。 驱动方面: 1:在平台设备文件中添加 一个按键,定义为唤醒源 archarmmach-s5pv210cppview plaincopystatic struct gpio_keys_button gpio_buttons = .gpio = S5PV210_GPH1(3), .code = KEY_F22, /对应 192 .desc = “F22“, .active_low = 1, .wakeup = 1, .debounce_interval =100, /去抖动 , static

2、struct gpio_keys_platform_data gpio_button_data = .buttons = gpio_buttons, .nbuttons = ARRAY_SIZE(gpio_buttons), ; static struct platform_device s3c_device_gpio_button = .name = “gpio-keys“, .id = -1, .num_resources = 0, .dev = .platform_data = platform_add_devices(smdkc110_devices, ARRAY_SIZE(smdkc

3、110_devices); 2:添加驱动kernel-v.20120620driversinputkeyboards3c-gpio-keys.c cppview plaincopystruct s3c_gpio_key int pin; int eint; int eintcfg; int inputcfg; ; struct s3c_gpio_key s3c_gpio_keys= /* .pin = S5PV210_GPH1(3), /at base wake up .eintcfg = 0X0fdesc ? button-desc : “gpio_keys“, bdata); cppvie

4、w plaincopystatic void gpio_keys_report_event(struct gpio_button_data *bdata) struct gpio_keys_button *button = bdata-button; struct input_dev *input = bdata-input; unsigned int type = button-type ?: EV_KEY; int state = (gpio_get_value(button-gpio) ? 1 : 0) button-active_low; /add by xiao2012-0620:f

5、or wake up mid when it on base. /上报事件处理下,因会发生系统唤醒后,又马上进入睡眠,造成一种假唤醒状态,所以当按键时,不时上报此事件来唤醒系统 if(button-code = 192) if(state) mod_timer( input_event(input, type, button-code, !state); input_sync(input); #ifdef key_debug printk(“gpio_keys_report_event-code =%d, state = %dn“,button-code,state); #endif 驱动按键

6、添加完成,内核能唤醒,但是 android 系统屏并不会点亮,所以需要修改源码, 让系统服务获取到此按键并作一些处理。 1:首先看下键值表:outtargetproductsmdkv210systemusrkeylayoutcppview plaincopyqwerty.kl # On an AT keyboard: ESC, F10 key 1 BACK WAKE_DROPPED key 68 MENU WAKE_DROPPED # on base wake up mid key 192 NULL WAKE_DROPPED /需要添加的键 NULL。WAKE_DROPPED:唤醒并点亮屏。

7、第一列:key 第二列: SCANCODE 是一个整数,是驱动里面定义的,在文件. /kernel/include/linux/input.h 第三列: KEYCODE 是一个字串,定义在你描述的布局文件 frameworks/base/include/ui/KeycodeLabels.h 另外可以设置相关的 FLAGS: SHIFT: 当按下,自动加上 SHIFT 键值 ALT:当按下,自动加上 ALT CAPS:当按下,自动带上 CAPS 大写 WAKE:当按下,当设备进入睡眠的时候,按下这个键将唤醒,而且发送消息给应用层。 WAKE_DROPPED:当按下,且设备正处于睡眠,设备被唤醒,

8、但是不发送消息给应用层。2:./frameworks/base/include/ui/keycodeLabels.hcppview plaincopystatic const KeycodeLabel KEYCODES = “BUTTON_MODE“, 110 , “NULL“, 111 , /在最后添加 NULL 按键, 键值为111 ,后续 android 根据键值来映射。 / NOTE: If you add a new keycode here you must also add it to several other files. / Refer to frameworks/base

9、/core/java/android/view/KeyEvent.java for the full list. NULL, 0 ; 3: ./ frameworks/base/native/include/android/Keycodes.h cppview plaincopyenum AKEYCODE_BUTTON_MODE = 110, AKEYCODE_NULL = 111, / 当 keyevent 处理按键事件时,isSystemKey 判断是否为系统按键才会继续上报上层,所以需要添加进去。 / NOTE: If you add a new keycode here you mus

10、t also add it to several other files. / Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. ; ./frameworks/base/libs/ui/input.java 同时 isSystemKey() 也要添加:cppview plaincopybool KeyEvent:isSystemKey(int32_t keyCode) switch (keyCode) case AKEYCODE_FOCUS: case AKEYCODE_SEARCH

11、: case AKEYCODE_NULL: / add by xiao2012-06-20 return true; return false; 4: ./frameworks/base/core/java/android/view/KeyEvent.javacppview plaincopy /根据键值 映射 为 KEYCODE_BUTTON_NULL ,为 PhoneWindowManager.java 提供按键目标。 public static final int KEYCODE_BUTTON_NULL = 111; 同时 这也修改:cppview plaincopy private s

12、tatic final int LAST_KEYCODE = KEYCODE_BUTTON_NULL; 5:./frameworks/base/core/res/res/values/attrs.xmlcppview plaincopy 通过以上的更改,新的键值就添加上去了,由于更改了 KeyEvent,影响到了 API, 所以 需要 make update-api 这样系统就会获取到这个 NULL 按键,并能够点亮屏幕了。 如果对新键值进行处理,可以通过获取相应的 keycode,对它进行处理;对于按键事件的 处理一般如下文件中 frameworks/policies/base/phone/

13、com/android/internal/policy/impl/PhoneWindowM anager.java interceptKeyBeforeQueueing 函数中处理。javaview plaincopy public int interceptKeyBeforeQueueing(long whenNanos, int keyCode, boolean down, int policyFlags, boolean isScreenOn) /add by xiao2012-06-20 :wakeup mid when it on base, else if(keyCode = KeyEvent.KEYCODE_BUTTON_NULL) /获取 NULL 按键,不让系统进入睡眠状态,释放按键时,进入可睡眠。 if(down) if(IS_MID_ONBASE = false) IS_MID_ONBASE = true;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号