From 7e3d678570d9e9849a249476275fec0a4bb1be1e Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 29 Dec 2009 15:41:09 -0800 Subject: [PATCH] Fixes bug of the number of injected monkey events. Returns the actual events number that has been injected, if any system error has occurred. --- .../src/com/android/commands/monkey/Monkey.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java index 7109bc6c4..74a721aa7 100644 --- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java +++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java @@ -717,7 +717,6 @@ public class Monkey { */ private int runMonkeyCycles() { int i = 0; - int lastKey = 0; boolean systemCrashed = false; @@ -753,7 +752,7 @@ public class Monkey { continue; } - if ((mVerbose > 0) && (i % 100) == 0 && i != 0 && lastKey == 0) { + if ((mVerbose > 0) && (i % 100) == 0 && i != 0) { System.out.println(" // Sending event #" + i); } @@ -774,16 +773,21 @@ public class Monkey { } } else if (injectCode == MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION) { systemCrashed = true; + System.err.println("** Error: RemoteException while injecting event."); } else if (injectCode == MonkeyEvent.INJECT_ERROR_SECURITY_EXCEPTION) { systemCrashed = !mIgnoreSecurityExceptions; + if (systemCrashed) { + System.err.println("** Error: SecurityException while injecting event."); + } } } else { // Event Source has signaled that we have no more events to process + System.err.println("** Error: Event source exhausted."); break; } } - // If we got this far, we succeeded! - return mCount; + System.out.println("Events injected: " + i); + return i; } /**