1.Power长按功能原理
当按下power时
Log.i(TAG, "PowerKey down, isScreenOn = " + isScreenOn);
interceptPowerKeyDown(!isScreenOn || hungUp
|| mVolumeDownKeyTriggered || mVolumeUpKeyTriggered);
private void interceptPowerKeyDown(boolean handled) {
mPowerKeyHandled = handled;
if (!handled || mChangeLongPressPowerKey) {
if(mChangeLongPressPowerKey) {
Log.d(TAG,"fast boot acquire cpu wakelock for timeout :"+(ViewConfiguration.getGlobalActionKeyTimeout()+100));
PowerManager.WakeLock fastBootWake = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "FastBootWake");
fastBootWake.acquire(ViewConfiguration.getGlobalActionKeyTimeout()+100);
}
mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout());

本文详细分析了Power键长按的功能原理,包括如何记录按下时间和判断事件消费。同时,探讨了组合键的实现,以Power+音量下截图为例,指出实现组合键需记录按键时间并判断时间差。值得注意的是,Power键在组合键生效时会忽略单独的点击或长按事件,这与音量键的状态有关。
最低0.47元/天 解锁文章
7954

被折叠的 条评论
为什么被折叠?



