summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-01-19 19:38:03 -0800
committerJeff Brown <jeffbrown@google.com>2011-01-20 17:54:53 -0800
commit98ab321927f1ea9ebb7ba6b5506ac6748b005555 (patch)
tree246eb6744ed1fae48a783cd4b302383a480bf9a1
parenta057567484888f206cd70ecc2dcb269b16f23718 (diff)
downloadandroid_development-98ab321927f1ea9ebb7ba6b5506ac6748b005555.tar.gz
android_development-98ab321927f1ea9ebb7ba6b5506ac6748b005555.tar.bz2
android_development-98ab321927f1ea9ebb7ba6b5506ac6748b005555.zip
Prevent monkey from turning off the screen. (DO NOT MERGE)
Bug: 3371251 Change-Id: I33005005fadc0f994f39fded10faafe21116f82a
-rw-r--r--cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
index f1edae11c..3d7834c0f 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
@@ -479,7 +479,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]) {
@@ -499,7 +499,13 @@ public class MonkeySourceRandom implements MonkeyEventSource {
} else {
lastKey = 1 + mRandom.nextInt(KeyEvent.getMaxKeyCode() - 1);
}
- } while (!PHYSICAL_KEY_EXISTS[lastKey]);
+
+ if (lastKey != KeyEvent.KEYCODE_POWER
+ && lastKey != KeyEvent.KEYCODE_ENDCALL
+ && PHYSICAL_KEY_EXISTS[lastKey]) {
+ break;
+ }
+ }
MonkeyKeyEvent e = new MonkeyKeyEvent(KeyEvent.ACTION_DOWN, lastKey);
mQ.addLast(e);