获取进程ID指令
adb shell ps | grep packagename
获取进程ID流量
adb shell cat /proc/pid/net/dev
import csv
import os
import string
import time
class Controller():
def __init__(self,count):
#定义测试的次数
self.count = count
self.alldata = [("timestamp","traffic")]
#单次测试过程
def testprocess(self):
#执行获取进程的命令
result = os.popen("adb shell ps | grep com.android.browser")
#进程ID
pid = result.readlines()[0].split(" ")[5]
#获取进程ID使用的流量
traffic = os.popen("adb shell cat /proc/"+pid + "/net/dev")
for line in traffic:
if "etho" in line :
#将所有空行换成#