OSDN Git Service

Prevent monkey from turning off the screen.
authorJeff Brown <jeffbrown@google.com>
Thu, 20 Jan 2011 03:38:03 +0000 (19:38 -0800)
committerJeff Brown <jeffbrown@google.com>
Thu, 20 Jan 2011 03:43:49 +0000 (19:43 -0800)
Bug: 3371251
Change-Id: Iadae29e8e4a67052746b8e2d2f5f542e4ee6dcc5

cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java

index 8ff9c92..ef60eac 100644 (file)
@@ -411,6 +411,11 @@ public class MonkeySourceRandom implements MonkeyEventSource {
             } 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);