The Android Monkey

The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare.  So what happens when that same monkey hits keys at random on your new G1 phone from HMK?  Android, as it turns out, has the answer…

As part of its Android SDK, Google has included the Monkey.  According to the documentation, “The Monkey is a command-line tool that that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.”  So basically it is the same thing as having a monkey randomly push buttons on the emulator or device, hence the name.  It does a great job of stress testing your applications, and includes a variety of arguments that allow you to sick the Monkey on a specific application, control the length of time it is active, and seed the random event generator.  Definitely something that should be used in application development.

However, when looking at the docs a bit more, the phrase I keyed in on was “emulator or device.”  Device?  You mean that The Monkey is also included on the only Android device currently in existence, the G1?  I am not sure how much damage a monkey can do, but my four year old once downloaded over a hundred dollars of material onto my phone… and that was before 3G networks existed.  Considering that this command line tool is included as part of the SDK itself, it wouldn’t be all that hard for a less than scrupulous person to hack into it and send your phone into a flurry of random activity.  When I run the Monkey on the emulator, it routinely sets alarms, changes contacts, and tries to log into my application.  On a phone, how long would it take for it to text message your girlfriend, delete that priceless photo of you at the Vikings game, or call 911?  Given the likelihood of malicious use, I suspect that the Monkey will not be available on devices as indicated, unless done through some kind of development only environment.

Comments

Returning visitor? Please login or register.

The Monkey tool cannot be activated remotely.  A hacker would have to rebuild with the platform rebuild system to activate all the parameters that would be necessary to execute scripts out side of using adb or the fastboot tool.  I’m certain that someone thought of this already and made it secure enough to be safe and open enough to be useful for a developer.

D474rpr Posted on: Apr 20, 2009 at 12:09 PM

D474rpr,

That is more or less what I expected, but was unable to verify it.  Thanks for the update!

Paul Bourdeaux Posted on: Apr 20, 2009 at 12:14 PM

Hi,
I am a android tool developer. I want to know how to code the monkey in android. Am using eclipse software to build it, so i cannot use monkey code directly in to make the application. So how to translate monkey code into pure java… Or else is there any plugins/ special activation needed for monkey in eclipse to use it????

please respond asap..

VG Posted on: Jul 28, 2010 at 03:00 AM

VG,

Check out the documentation for using the Monkey to test your applications. http://developer.android.com/guide/developing/tools/monkey.html  It is fairly simple to launch from the adb command line.

Paul Bourdeaux Posted on: Jul 29, 2010 at 09:57 AM

Hi, i know to do in cmd. But hen i need to do in coding. can you help.

VG Posted on: Jul 29, 2010 at 01:02 PM

VG,

I am afraid I don’t understand what you are asking.  The Monkey is a tool that is used to stress test applications - it isn’t something that you can code against.  You cannot create an application that activates the Monkey programatically. 

OK, on second thought, I think there MIGHT be a way (strong emphasis on the might).  But I can’t think of any non-malicious reason to do it.  Can you tell me more about WHY you want to access the Monkey from inside an application.

Paul Bourdeaux Posted on: Jul 29, 2010 at 02:07 PM

Because am developing a a tool for android phones to capture every action whatever the user is doing with the phone.So i need the coding method of which else to follow to acheive this. I have tried for monkey coding. But then if i get any extraction of it to try out this, i think it can be proceeded.And id possible may i know what is the equivalent code for adb shell monkey 10. 

Help me out. thanx

VG Posted on: Aug 02, 2010 at 02:27 AM

So you are trying to write a keystroke logger for an android phone?  I am not even going to begin to explain the privacy violations and ethical issues that raises.

Fortunately, what you are asking for is impossible anyway.  The logging system in the monkey does not work the way you are proposing - it loggs what actions it will take, not what actions are taken.

Paul Bourdeaux Posted on: Aug 03, 2010 at 10:02 AM

Leave A Comment

Please help us stop spam by answering the question below: