1

这个脚本有什么问题?

# 导入此程序使用的 monkeyrunner 模块
从 com.android.monkeyrunner 导入 MonkeyRunner,MonkeyDevice
# 连接到当前设备,返回一个 MonkeyDevice 对象
设备 = MonkeyRunner.waitForConnection()
#重启
device.reboot('无')

我还尝试更改 bootloadType。我尝试使用的最后一行是 device.reboot('bootloader') 和 device.reboot('recovery'),但它也不起作用。

4

1 回答 1

0

Android 开发人员在此处发布的内容如下:

“rebo​​ot”实际上是硬件重启,而“stop”/“start”是软件重启。

理想情况下,对于模拟器,您应该能够使用:

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

...但是这里有一个针对模拟器 >= 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

这个脚本可以通过传入一个特定模拟器的序列号来杀死(可以使用“adb get-serialno”获取序列号)

我很想看看其他人的想法/他们正在自动重启模拟器的方式。

于 2011-03-07T11:37:02.633 回答