Android 按键 机器息屏瞬间立即按power键,机器亮屏直接进入系统,不再锁屏
Posted 王睿丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 按键 机器息屏瞬间立即按power键,机器亮屏直接进入系统,不再锁屏相关的知识,希望对你有一定的参考价值。
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
public long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event,int policyFlags)
case KeyEvent.KEYCODE_POWER:
//发送广播给 KeyguardViewMediator.java
Intent mIntent = new Intent("xxx.delayLockScreen");
mContext.sendBroadcast(mIntent);
frameworks/base/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
private int LockScreenNum = 0; //锁屏计数器
private void setupLocked()
//注册广播
IntentFilter filter1 = new IntentFilter();
filter1.addAction("xxx.delayLockScreen");
mBroadcastDispatcher.registerReceiver(myDelayLockScreenBroadcastReceiver, filter1);
public void onFinishedGoingToSleep(int why, boolean cameraGestureTriggered)
if (mPendingLock)
//start
new Thread(new Runnable()
@Override
public void run()
try
Thread.sleep(500);
//根据计数器判断睡眠模式是否为深度睡眠
if (LockScreenNum==0)
doKeyguardLocked(null);
mPendingLock = false;
LockScreenNum = 0;
catch (InterruptedException e)
e.printStackTrace();
).start();
//end
private final BroadcastReceiver myDelayLockScreenBroadcastReceiver = new BroadcastReceiver()
@Override
public void onReceive(Context context, Intent intent)
//如果屏幕仍然被立即点击,计数器将+1
if (mPendingLock)
LockScreenNum++;
;
以上是关于Android 按键 机器息屏瞬间立即按power键,机器亮屏直接进入系统,不再锁屏的主要内容,如果未能解决你的问题,请参考以下文章
ANDROID的怎么添加长按键,我的机器没HOME,想长按键返回HOME,我看别的机子可以的。求助!!
如何在Android平板电脑POWER按钮菜单中添加休眠功能