开发者

Android Exerciser Monkey starts playing audio files at random

开发者 https://www.devze.com 2023-03-23 13:40 出处:网络
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 th

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=5开发者_开发技巧8.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


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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号