Android Exerciser Monkey starts playing audio files at random
Asked Answered
C

2

12

I'm running exerciser monkey to test my android app. As part of my app I play media files which give the pronunciation of a words. I've put the files in a directory where they aren't readable by the Android's Music player. However, the exerciser monkey throws some sequence of events which seem to activate the music player, which then repetitively play the beginning of another mp3 file (which is not from my app) during its testing. How is it doing this, and is it something I should be concerned with?

Additional info: even when I disable MediaPlayer in my app, the problem still occurs. FWIW, here is the series of outputs from the exerciser monkey leading up to the command (the last one) which generates the sound:

   // Rejecting start of Intent { act=android.intent.action.VIEW dat=http://www.myurl.com/ cmp=com.android.browser/.BrowserActivity } in package com.android.browser
:Sending Pointer ACTION_DOWN x=437.0 y=183.0
:Sending Pointer ACTION_UP x=450.0 y=158.0
:Sending Pointer ACTION_DOWN x=5.0 y=58.0
:Sending Pointer ACTION_UP x=-4.0 y=58.0
:Sending Pointer ACTION_MOVE x=2.0 y=-2.0 <=== sound generated from this one

This is the output of logcat at the point of the problem:

I/AudioService(  101):  AudioFocus  requestAudioFocus() from android.media.AudioManager@40518af0com.android.music.MediaPlaybackService$3@405218f8
I/AudioService(  101):   Remote Control   registerMediaButtonEventReceiver() for ComponentInfo{com.google.android.music/com.android.music.MediaButtonIntentReceiver}
W/AudioFlinger(   68): write blocked for 159 msecs, 26 delayed writes, thread 0xea00
D/AudioHardwareQSD(   68): AudioHardware pcm playback is going to standby.
D/dalvikvm(  319): GC_EXPLICIT freed 7K, 51% free 2839K/5767K, external 1625K/2137K, paused 74ms
Corsica answered 27/7, 2011 at 16:33 Comment(0)
J
7

I think this has to do with the fact the monkey sends various key codes including key codes for hardware keys that may not even exist on the device under test.

I have experienced a similar issue using the monkey and investigated it by providing the -v -v options (repeated -v increases the debugging level) and slowing the rate down using the --throttle option I'd also experimented to find a small number of actions that made it occur.

My command line ended up reading:

adb shell monkey -p package.undertest.com -s 214765 --throttle 500 -v -v 130

This revealed that just before the media player started, i got the following logged:

Sleeping for 500 milliseconds
:SendKey (ACTION_DOWN): 90    // KEYCODE_FORWARD
:SendKey (ACTION_UP): 90    // KEYCODE_FORWARD

I was then able to confirm that KEYCODE_FORWARD does start my media player (doubleTwist) on my Galaxy S by issuing the following command after I'd stopped the media player:

adb shell input keyevent 90

Note that the 90 is the keycode listed in the log above.

By changing my command line to the monkey to add "--pct-nav 0" that successfully stopped it starting the media player.

I don't know if it might be a different key code in your case, so you might need to experiment and it may not suit your purposes in using the monkey to turn off all the basic navigation events by setting --pct-nav 0.

Joelie answered 27/10, 2011 at 13:56 Comment(0)
N
0

Does your app have any features that launch other services or applications that play music? For example if you have a button that launches an intent to change the ringer volume the monkey would press that causing ringer noises. (In my experience the monkey with default settings goes outside the application and changes ringer settings anyway)

Nuris answered 27/7, 2011 at 16:44 Comment(5)
Yes, it uses the MediaPlayer. However, even when I disable the the play command, which creates a media player, the problem still occurs. On top of that, it never gets to the Activity where the the media player gets invoked.Corsica
You could try watching the logcat while the monkey is running, and see if it gives you any extra information when a sound plays.Nuris
Good idea. I've posted the results into my question.Corsica
ok well AudioManager is being called so your application must be doing something with ringer or notification sounds.Nuris
Nope. Nothing. It's a very conventional app. As you mentioned, monkey changes ringer volume, although you do nothing with it in your app. It does mine as well. I'm thinking whatever events it throws at the UI does something similar, although I'd like to know how.Corsica

© 2022 - 2024 — McMap. All rights reserved.