| commit | 8a2659dc0db131ec6c01e5bfc25185dd51aa1275 | [log] [tgz] |
|---|---|---|
| author | Jeff Brown <jeffbrown@google.com> | Wed Jan 19 19:38:03 2011 -0800 |
| committer | Jeff Brown <jeffbrown@google.com> | Wed Jan 19 19:43:49 2011 -0800 |
| tree | 7f72d56b5e68223d1bf7b2e6ddb05c064aedbaed | |
| parent | 953dbee407ebffd4bd340aac5dc5aea469fa2bdf [diff] |
Prevent monkey from turning off the screen. Bug: 3371251 Change-Id: Iadae29e8e4a67052746b8e2d2f5f542e4ee6dcc5
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java index 8ff9c92..ef60eac 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
@@ -411,6 +411,11 @@ } else { 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; + } } while (!PHYSICAL_KEY_EXISTS[lastKey]); MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, lastKey);