本文共 2380 字,大约阅读时间需要 7 分钟。
import osimport loggingfile = open("AndroidManifest.xml")_adb_startActivity="adb shell am start -n "packageName=""def _create_cmd(cmd, param1,param2 ): res="" res=res+cmd+param1+"/"+param2 print res return resdef _pictrue(cmd, param1): res="" res=res+cmd+param1+".png" print res return res while 1: line = file.readline() if not line: break if "manifest" in line and "package" in line: arr=line.split(" ") for i in range(len(arr)): if "package" in arr[i]: names=arr[i].split("\"") packageName=names[1] print packageName if "activity" in line: arr=line.split(" ") for i in range(len(arr)): if "android:name" in arr[i]: names=arr[i].split("\"") #print type(names[1]) cmd = _create_cmd(_adb_startActivity,packageName,names[1]) assert os.system(cmd) == 0 os.system("sleep 5") os.system("adb pull /dev/graphics/fb0 fb0") os.system("python rgb565torgb888.pyfb0.888") cmd = _pictrue("convert -depth 8 -size 320x480 RGB:fb0.888 ",names[1]) assert os.system(cmd) == 0 #os.system("convert -depth 8 -size 320x480 RGB:fb0.888 fb0.png") #print names[1]
import os 2 from xml.dom import minidom 3 file = open("AndroidManifest.xml") 4 _adb_startActivity="adb shell am start -n " 5 packageName="" 6 7 8 def _create_cmd(cmd, param1,param2 ): 9 res="" 10 res=res+cmd+param1+"/"+param2 11 print res 12 return res 13 14 def _pictrue(cmd, param1): 15 res="" 16 res=res+cmd+param1+".png" 17 print res 18 return res 19 20 21 22 doc = minidom.parse( "AndroidManifest.xml" ) 23 root = doc.documentElement 24 packageName=root.getAttribute("package") 25 activities = root.getElementsByTagName( "activity" ) 26 for activity in activities: 27 activityName=activity.getAttribute("android:name") 28 activity.getAttribute("android:name") 29 cmd = _create_cmd(_adb_startActivity,packageName,activityName) 30 assert os.system(cmd) == 0 31 os.system("sleep 5") 32 os.system("adb pull /dev/graphics/fb0 fb0") 33 os.system("python rgb565torgb888.pyfb0.888") 34 cmd = _pictrue("convert -depth 8 -size 320x480 RGB:fb0.888 ",activityName) 35 assert os.system(cmd) == 0
转载地址:http://cyxyo.baihongyu.com/