From 8a2659dc0db131ec6c01e5bfc25185dd51aa1275 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 19 Jan 2011 19:38:03 -0800 Subject: [PATCH] Prevent monkey from turning off the screen. Bug: 3371251 Change-Id: Iadae29e8e4a67052746b8e2d2f5f542e4ee6dcc5 --- .../src/com/android/commands/monkey/MonkeySourceRandom.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java index 8ff9c928f..ef60eac16 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 @@ 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);