JB2上如何实现按power键亮屏的时候,能把触摸板上的home/menu/back虚拟按键的背光点亮?
来源:互联网 发布:网络视频服务器参数 编辑:程序博客网 时间:2024/06/09 16:01
在android 4.2上的版本,google defautl就已经把触摸板上虚拟按键的背光功能去掉了,如想实现按power键亮屏的时候,能把home/menu/back这些键的背光灯点亮,请参考下面的实现方法:
KeyguardViewMediator.java
1,
public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils) {
mContext = context;
mPM=(PowerManager) context.getSystemService(Context.POWER_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
//add code here ===============
mButtonWakelock=mPM.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,"button backlight");
//add code here ===============
2,
private void handleWakeWhenReady(int keyCode, int wakeMSGId) {
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, ">>>handleWakeWhenReady(" + keyCode + ") Before--synchronized (KeyguardViewMediator.this) wakeMSGId = " + wakeMSGId); /// M:
synchronized (KeyguardViewMediator.this) {
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, "handleWakeWhenReady(" + keyCode + ") wakeMSGId = " + wakeMSGId);
// this should result in a call to 'poke wakelock' which will set a timeout
// on releasing the wakelock
if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) {
// poke wakelock ourselves if keyguard is no longer active
KeyguardUtils.xlogD(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves");
userActivity();
}
/**
* Now that the keyguard is ready and has poked the wake lock, we can
* release the handoff wakelock
*/
mWakeAndHandOff.release();
//add code here =============
mButtonWakelock.acquire(3000);
//add code here =============
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, "<<<handleWakeWhenReady(" + keyCode + ") wakeMSGId = " + wakeMSGId);
}
}
3,
keyguardviewmediator.java
private void handleKeyguardDone(boolean wakeup) {
KeyguardUtils.xlogD(TAG, "handleKeyguardDone, wakeup=" + wakeup);
//add code here ================
if (mButtonWakelock.isHeld())
mButtonWakelock.release();
//add code here ================
handleHide();
if (wakeup) {
wakeUp();
}
sendUserPresentBroadcast();
}
4,
phonewindowmanager.java
/** {@inheritDoc} */
@Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
int result;
if ((isScreenOn && !mHeadless) || (isInjected && !isWakeKey)) {
// When the screen is on or if the key is injected pass the key to the application.
result = ACTION_PASS_TO_USER;
} else {
// When the screen is off and the key is not injected, determine whether
// to wake the device but don't pass the key to the application.
result = 0;
if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) {
if (keyguardActive) {
// If the keyguard is showing, let it wake the device when ready.
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
} else {
// Otherwise, wake the device ourselves.
result |= ACTION_WAKE_UP;
//add code her =================================
mKeyguardMediator.pokeWakelock();
//add code her =================================
}
}
}
5,
KeyguardViewMediator.java
//add by mtk
public void pokeWakelock()
{ mButtonWakelock.acquire(3000);
}
//add by mtk
KeyguardViewMediator.java
1,
public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils) {
mContext = context;
mPM=(PowerManager) context.getSystemService(Context.POWER_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
//add code here ===============
mButtonWakelock=mPM.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,"button backlight");
//add code here ===============
2,
private void handleWakeWhenReady(int keyCode, int wakeMSGId) {
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, ">>>handleWakeWhenReady(" + keyCode + ") Before--synchronized (KeyguardViewMediator.this) wakeMSGId = " + wakeMSGId); /// M:
synchronized (KeyguardViewMediator.this) {
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, "handleWakeWhenReady(" + keyCode + ") wakeMSGId = " + wakeMSGId);
// this should result in a call to 'poke wakelock' which will set a timeout
// on releasing the wakelock
if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) {
// poke wakelock ourselves if keyguard is no longer active
KeyguardUtils.xlogD(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves");
userActivity();
}
/**
* Now that the keyguard is ready and has poked the wake lock, we can
* release the handoff wakelock
*/
mWakeAndHandOff.release();
//add code here =============
mButtonWakelock.acquire(3000);
//add code here =============
if (DBG_WAKE) KeyguardUtils.xlogD(TAG, "<<<handleWakeWhenReady(" + keyCode + ") wakeMSGId = " + wakeMSGId);
}
}
3,
keyguardviewmediator.java
private void handleKeyguardDone(boolean wakeup) {
KeyguardUtils.xlogD(TAG, "handleKeyguardDone, wakeup=" + wakeup);
//add code here ================
if (mButtonWakelock.isHeld())
mButtonWakelock.release();
//add code here ================
handleHide();
if (wakeup) {
wakeUp();
}
sendUserPresentBroadcast();
}
4,
phonewindowmanager.java
/** {@inheritDoc} */
@Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
int result;
if ((isScreenOn && !mHeadless) || (isInjected && !isWakeKey)) {
// When the screen is on or if the key is injected pass the key to the application.
result = ACTION_PASS_TO_USER;
} else {
// When the screen is off and the key is not injected, determine whether
// to wake the device but don't pass the key to the application.
result = 0;
if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) {
if (keyguardActive) {
// If the keyguard is showing, let it wake the device when ready.
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
} else {
// Otherwise, wake the device ourselves.
result |= ACTION_WAKE_UP;
//add code her =================================
mKeyguardMediator.pokeWakelock();
//add code her =================================
}
}
}
5,
KeyguardViewMediator.java
//add by mtk
public void pokeWakelock()
{ mButtonWakelock.acquire(3000);
}
//add by mtk
- JB2上如何实现按power键亮屏的时候,能把触摸板上的home/menu/back虚拟按键的背光点亮?
- JB2上如何实现按power键亮屏的时候,能把触摸板上的home/menu/back虚拟按键的背光点亮?
- android如何屏蔽home back power按键(现保存以后很可能会需要的)
- 部分安卓版本虚拟按键上没有Menu按键的解决方法
- android隐藏底部虚拟键Navigation Bar实现全屏(虚拟按键home,back,menu)
- 关于89 jb2上的自动设置按键唤醒系统的功能以及L版本上设置唤醒键
- Android 物理按键的监听Back,Menu和音量(不包括home键,锁屏键,以及长按菜单的监听
- Atitit.android js 的键盘按键检测Back键Home键和Menu键事件
- 手机上Menu 按键的初步认识【1】
- Android中对menu、home、back键的监听
- Android中对menu、home、back键的监听
- Android中对menu、home、back键的监听
- Android设备Home、Menu和Back返回键的监听
- 监听Home和Back物理按键的学习总结
- android 源码 在状态栏添加 虚拟按键(back,home,menu)
- 如何在Web前端上点亮你的技能树
- imx6q上的背光驱动分析
- 如何在Cocos2dx中处理Android os的设备的Menu和Back按键的响应处理
- 如何确认一个应用程序的安装位置
- Android ImageView 图片设置为透明
- ObjC学习5-变量和数据类型
- 问题描述: 安装&重启完成后,我输入命令xm list,提示错误 xm list Can't find hypervisor information in sysfs 解决方法: # mv /
- 一位IT人士之所想
- JB2上如何实现按power键亮屏的时候,能把触摸板上的home/menu/back虚拟按键的背光点亮?
- Effective C++读书笔记 第二部分 构造/析构/赋值运算
- c++读写文件
- 如何添加一个jni库模块到整理编译中?
- dfdsfsdfsdfsdf
- 《C和指针》读书笔记
- 应用程序域
- word/half-word/byte概念
- InstallShield如何调用批处理文件