2011-02-11 64 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。

相關問題