From 82df76b040cc13c2df4be141edfb2d29e439f57a Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 20 Jan 2011 17:41:18 -0800 Subject: [PATCH] Really don't send POWER or ENDCALL. Change-Id: If55c6bc7565a9a6b493da16fac5c7ad3c621684f --- .../android/commands/monkey/MonkeySourceRandom.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java index ef60eac16..af740b328 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java @@ -391,7 +391,7 @@ public class MonkeySourceRandom implements MonkeyEventSource { } // The remaining event categories are injected as key events - do { + for (;;) { if (cls < mFactors[FACTOR_NAV]) { lastKey = NAV_KEYS[mRandom.nextInt(NAV_KEYS.length)]; } else if (cls < mFactors[FACTOR_MAJORNAV]) { @@ -412,11 +412,12 @@ public class MonkeySourceRandom implements MonkeyEventSource { lastKey = 1 + mRandom.nextInt(KeyEvent.getMaxKeyCode() - 1); } - if (lastKey == KeyEvent.KEYCODE_POWER || lastKey == KeyEvent.KEYCODE_ENDCALL) { - // Make sure we don't inadvertently turn off the device. - continue; + if (lastKey != KeyEvent.KEYCODE_POWER + && lastKey != KeyEvent.KEYCODE_ENDCALL + && PHYSICAL_KEY_EXISTS[lastKey]) { + break; } - } while (!PHYSICAL_KEY_EXISTS[lastKey]); + } MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, lastKey); mQ.addLast(e);