Android 11.0 机器息屏瞬间立即按power键,机器亮屏并直接进入系统,不再锁屏
Posted 王睿丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 11.0 机器息屏瞬间立即按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 11.0 机器息屏瞬间立即按power键,机器亮屏并直接进入系统,不再锁屏的主要内容,如果未能解决你的问题,请参考以下文章
Android 11.0 修改在锁屏界面,按“△”键不能解锁,只能按空格键解锁
Android 11.0 修复在锁屏界面连续按锁屏键,需要按多次空格键才能解锁的Bug
Android 11.0 在闹钟APK,长按进入夜间模式,松开退出夜间模式