我有一个简单的代码片段,如下所示,使用 AVC 对 Nexus3 手机执行一些顺序操作。
#! /usr/bin/python
import sys, os, time
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.adb.adbclient import AdbClient
#from com.dtmilano.android.viewclient import ViewClient
adbc=AdbClient(serialno='.*')
print 'taking snapshot...'
adbc.takeSnapshot()
print 'touch 1st time...'
adbc.touch(50,70)
time.sleep(1)
print 'touch 2nd time...'
adbc.touch(50,70)
在 touch() 之前使用 takeSnapshot() 代码,touch() 失败,出现以下异常:
touch 1st time...
sending 0015shell:input tap 50 70
shell(cmd=input tap 50 70)
__send(shell:input tap 50 70, checkok=True, reconnect=False)
__checkOk()
checkConnected()
checkConnected: returning True
setAlarm(150)
__checkOk: recv= ''
setAlarm(0)
Traceback (most recent call last):
File "/home/swang/engine/test.py", line 19, in <module>
adbc.touch(50,70)
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 430, in touch
self.shell('input tap %d %d' % (x, y))
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 260, in shell
self.__send('shell:%s' % cmd, checkok=True, reconnect=False)
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 157, in __send
self.__checkOk()
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 193, in __checkOk
raise RuntimeError("ERROR: %s %s" % (repr(recv), error))
RuntimeError: ERROR: ''
Closing socket... <socket._socketobject object at 0xa9da60>
但是如果我删除了 takeSnapshot(),下面的 2 touch() 就会成功。我正在使用最近的 AVC 版本。我在这里忽略了什么吗?