Skip to content

Commit

Permalink
Corrected repeat count for key repeat in input device.
Browse files Browse the repository at this point in the history
Previously the key event repeat count was always zero when the repeated
key down events was generated by the input device in the Linux kernel.

Change-Id: I9e295ca41ffe7324f54083f0a493e073187feb28
  • Loading branch information
Kristian Dreher authored and hyperb1iss committed Jul 22, 2010
1 parent c9f071f commit 55710a1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion phone/com/android/internal/policy/impl/PhoneWindowManager.java
Expand Up @@ -285,6 +285,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
ShortcutManager mShortcutManager;
PowerManager.WakeLock mBroadcastWakeLock;

int lastKeyCode = KeyEvent.getMaxKeyCode() + 1; //invalid code
int keyRepeatCount = 0;

class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
Expand Down Expand Up @@ -1946,6 +1949,18 @@ else if (isWakeKey && isKeyUp) {
boolean down = event.value != 0;

if (type == RawInputEvent.EV_KEY) {
if (down) {
if (code == lastKeyCode) {
keyRepeatCount++;
} else {
keyRepeatCount = 0;
}
lastKeyCode = code;

This comment has been minimized.

Copy link
@billytehkid

billytehkid Jul 23, 2010

Swap this line with the line above it, moving it into the else{}. No need to set lastKeyCode if we already know it's the same, right?

} else {
keyRepeatCount = 0;
lastKeyCode = KeyEvent.getMaxKeyCode() + 1; //invalid code
}

if (code == KeyEvent.KEYCODE_ENDCALL
|| code == KeyEvent.KEYCODE_POWER) {
if (down) {
Expand Down Expand Up @@ -2029,7 +2044,7 @@ else if (isWakeKey && isKeyUp) {
// only do it if the showing app doesn't process the key on its own.
KeyEvent keyEvent = new KeyEvent(event.when, event.when,
down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP,
code, 0);
code, keyRepeatCount);
mBroadcastWakeLock.acquire();
mHandler.post(new PassHeadsetKey(keyEvent));
}
Expand Down

0 comments on commit 55710a1

Please sign in to comment.