Android Examer Monkey 开始随机播放音频文件

发布于 2024-11-26 12:52:44 字数 1335 浏览 2 评论 0原文

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

附加信息:即使我在应用程序中禁用 MediaPlayer,问题仍然会发生。 FWIW,这里是练习猴子的一系列输出,直到生成声音的命令(最后一个):

   // 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 的输出:

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'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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如歌彻婉言 2024-12-03 12:52:44

我认为这与猴子发送各种按键代码包括硬件按键的按键代码有关,而这些按键代码甚至可能不存在于被测设备上

我在使用猴子时遇到了类似的问题,并通过提供 -v -v 选项(重复 -v 增加调试级别)并使用 --throttle 选项减慢速度进行了调查,我还尝试找到了一小部分导致其发生的行动。

我的命令行最终显示为:

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

这表明就在媒体播放器启动之前,我记录了以下内容:

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

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

adb shell input keyevent 90

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

通过将我的命令行更改为猴子添加“--pct-nav 0”,成功阻止了它启动媒体播放器。

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

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.

岁月苍老的讽刺 2024-12-03 12:52:44

您的应用程序是否具有启动其他播放音乐的服务或应用程序的功能?例如,如果您有一个按钮可以启动改变铃声音量的意图,那么猴子就会按下该按钮,从而导致铃声噪音。 (根据我的经验,具有默认设置的猴子会超出应用程序并更改铃声设置)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文