Android Exerciser Monkey开始随机播放音频文件 [英] Android Exerciser Monkey starts playing audio files at random

查看:167
本文介绍了Android Exerciser Monkey开始随机播放音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行运动猴子来测试我的android应用.作为我的应用程序的一部分,我播放媒体文件,这些文件给出单词的发音.我将文件放在Android音乐播放器无法读取的目录中.但是,锻炼猴子会抛出一些事件序列,这些事件似乎激活了音乐播放器,然后在测试过程中重复播放了另一个mp3文件(不是我的应用程序中的文件)的开头.它是如何做到的,这是我应该关注的事情吗?

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?

其他信息:即使在我的应用程序中禁用MediaPlayer时,仍然会出现此问题. FWIW,这是运动猴的一系列输出,直至产生声音的命令(最后一个):

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

这是问题所在时logcat的输出:

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.

我在使用猴子时遇到了类似的问题,并通过提供-v -v选项(重复使用-v增加了调试级别)并使用--throttle选项来减慢了速度,对此我也进行了尝试以查找导致它发生的少量动作.

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

然后,我可以在停止媒体播放器后发出以下命令来确认KEYCODE_FORWARD确实在我的Galaxy S上启动了媒体播放器(doubleTwist):

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

请注意,90是上面日志中列出的键控代码.

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

通过将猴子的命令行更改为添加"--pct-nav 0",成功停止了它的启动媒体播放器.

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

我不知道这是否与您的情况不同,因此您可能需要进行实验,并且可能不适合您通过设置--pct使用猴子关闭所有基本导航事件的目的. -nav 0.

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.

这篇关于Android Exerciser Monkey开始随机播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆