From 3d0ea72dd74bb0a7ad082a82dbf53df11a4f487c Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Wed, 21 Oct 2009 22:58:29 -0400 Subject: [PATCH] Add WindowManagerPolicy.allowKeyRepeat() method for disabling key repeats. Part of a fix for bug b/2198537 Change-Id: I99dc64772fa7644b12432d5549603025196ea3e2 Signed-off-by: Mike Lockwood --- core/java/android/view/WindowManagerPolicy.java | 5 +++++ services/java/com/android/server/WindowManagerService.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 916fc2d78cb52..1ab46fc0a6ab5 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -868,4 +868,9 @@ public interface WindowManagerPolicy { * requesting this is no longer visible. */ public void screenOnStoppedLw(); + + /** + * Return false to disable key repeat events from being generated. + */ + public boolean allowKeyRepeat(); } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 9caa38602f00d..e743513ab924f 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -6227,6 +6227,13 @@ public class WindowManagerService extends IWindowManager.Stub lt.sample("2 got event ", System.nanoTime() - ev.whenNano); } + if (lastKey != null && !mPolicy.allowKeyRepeat()) { + // cancel key repeat at the request of the policy. + lastKey = null; + downTime = 0; + lastKeyTime = curTime; + nextKeyTime = curTime + LONG_WAIT; + } try { if (ev != null) { curTime = SystemClock.uptimeMillis();