完善资料让更多小伙伴认识你,还能领取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"); |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
2031 浏览 1 评论
synopsys 的design ware:DW_fpv_div,浮点数除法器,默认32位下,想提升覆盖率(TMAX),如果用功能case去提升覆盖率呢?
2571 浏览 1 评论
RK3588 GStreamer调试四路鱼眼摄像头四宫格显示报错
5346 浏览 1 评论
【飞凌嵌入式OK3576-C开发板体验】RKNN神经网络-YOLO图像识别
254 浏览 0 评论
【飞凌嵌入式OK3576-C开发板体验】SSH远程登录网络配置及CAN通讯
1336 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 17:21 , Processed in 0.584469 second(s), Total 73, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号