1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
一般对于开发者来说,我们看的最多的是下面两个函数
// 用于处理一些特殊的按键 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) // 处理一般性的按键 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) 实现双击home键切换到 recent app 文件:frameworksbaseservicescorejavacomandroidserverpolicyPhoneWindowManager.java diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index cebf0a7..9ec5dbb 100755 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -842,6 +853,77 @@ public class PhoneWindowManager implements WindowManagerPolicy { private float mdeltax, mdeltay; boolean keydown; + boolean homeDownDoubleClick = false; + long lastHomeDownTime=0; + long lastHomeUpTime=0; @@ -6084,7 +6252,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } // Basic policy based on interactive state. - int result; + int result = 0; boolean isBox = "box".equals(SystemProperties.get("ro.target.product")); boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 || event.isWakeKey(); @@ -6421,6 +6589,40 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (useHapticFeedback) { performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); } + /** + * add by wutao 20190809 + * Double-click the home button to switch to the recent app + */ + if(keyCode == KeyEvent.KEYCODE_HOME){ + if(down){ + // this is home down + if(((event.getEventTime() - lastHomeDownTime) < 500)){ + homeDownDoubleClick = true; + }else{ + homeDownDoubleClick = false; + } + lastHomeDownTime = event.getEventTime(); + } else { + // then home up comes + Log.d(TAG,"homeDownDoubleClick="+homeDownDoubleClick+",lastHomeDownTime="+lastHomeDownTime+",lastHomeUpTime="+lastHomeUpTime+",this home up="+event.getEventTime()); + if(homeDownDoubleClick && ((event.getEventTime() - lastHomeUpTime) < 500)){ + Log.d(TAG,"double click on home detected"); + try { + StatusBarManagerInternal statu***ar = getStatusBarManagerInternal(); + if (statu***ar != null) { + statu***ar.preloadRecentApps(); + statu***ar.toggleRecentApps(); + } + } catch (Exception e) { + e.printStackTrace(); + mStatusBarService = null; + } + //result |= ACTION_WAKE_UP; + return result; + } + lastHomeUpTime = event.getEventTime(); + } + } if (isWakeKey) { wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey, "android.policy:KEY"); |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于米尔瑞芯微RK3576核心板/开发板的人脸疲劳检测应用方案
533 浏览 0 评论
803 浏览 1 评论
700 浏览 1 评论
1926 浏览 1 评论
3171 浏览 1 评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 16:31 , Processed in 0.515359 second(s), Total 70, Slave 54 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号