# coding:utf-8
import os
import time
def readDevicesList():
p = os.popen('adb devices')
devicesList = p.read()
p.close()
lists = devicesList.split("\n")
devicesNames = []
for item in lists:
if (item.strip() == ""):
continue
elif (item.startswith("List of")):
continue
else:
devicesNames.append(item.split("\t")[0])
return devicesNames
def getRealDeviceName(deviceId):
p = os.popen('adb -s ' + deviceId + ' shell getprop ro.product.manufacturer')
manufacturer = p.read()
p.close()
p = os.popen('adb -s ' + deviceId + ' shell getprop ro.product.model')
model = p.read()
p.close()
return manufacturer.strip() + " " + model.strip()
def getPhoneState(deviceId):
# adb shell 后的命令用双引号,否则执行出错!!!!
p = os.popen('adb -s ' + deviceId + ' shell "dumpsys telephony.registry|grep \"mCallState\""')
res = p.read().splitlines()[0].split('=')[1]
p.close()
if res == '0':
res = 'idle'
elif res == '1':
res = 'ringing'
elif res == '2':
res = 'calling'
return res.strip()
def callPhone():
call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:18620332060')
call.close()
def answerPhone():
answer = os.popen('adb shell input keyevent 5')
answer.close()
def offHookPhone():
off = os.popen('adb shell input keyevent 6')
off.close()
sleep_time = 1.0
while 1:
answerPhone()
time.sleep(sleep_time)
工厂手机电话测试Python 脚本
最新推荐文章于 2022-06-24 14:11:51 发布