2011-02-11 59 views
1

什么是错的这个脚本?如何使用monkeyrunner我重新启动Android模拟器?

# Imports the monkeyrunner modules used by this program
 from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
#Reboot
device.reboot('None')

我也试图改变bootloadType。最后一行我,device.reboot(“引导程序”)和device.reboot(“复苏”)试过的insted的,但它也不能工作。

回答

0

发表的Android开发人员here说以下内容:

“重启”是有效的硬件 重启,而“停止” /“开始”是 软件重新启动。

对于模拟器最好你应该能够使用:

device.shell('stop'); 
device.shell('start'); 

...但有一个bug引发here针对启动/停止模拟器> = 2.2。

就个人而言,我使用了一个讨厌的小shell脚本杀死所有的仿真器实例,然后再次启动模拟器:在一个特定的仿真器的序列号传递给杀

#!/bin/bash 

pgrep -x "emulator" > /dev/null 
until [ $? -eq 1 ]; do 
    kill `pgrep -x "emulator" | cut -c 1-6` 
    sleep 2 
    pgrep -x "emulator" 
done 

# start emulator normally... 
exit 0 

该脚本可以细化关闭(可以得到使用“亚行GET-的SerialNo”的序列号)在看到别人怎么想/办法他们正在自动化仿真器的重启

我会intereted。

相关问题