注释挺详细了,直接上全部代码,欢迎各位大佬批评指正。
# encoding:utf-8
import csv
import os
import time
class App(object):
def __init__(self, package, acticity):
self.content = ""
self.startTime = 0
self.ThisTime = 0
self.TotalTime = 0
self.WaitTime = 0
self.result = []
self.package = package.strip()
self.activity = acticity.strip()
# 启动App
def LaunchApp(self):
cmd = 'adb shell am start -W -n {}/{}'.format(self.package,self.activity)
self.content = os.popen(cmd)
# 热启动停止App
def StopHotApp(self):
cmd = 'adb shell input keyevent 3'
os.popen(cmd)
# 冷启动停止App
def StopApp(self):
cmd = 'adb shell am force-stop {}'.format(self.package)
os.popen(cmd)
# 获取启动时间
def GetLaunchedTime(self):
# print( self.content.readlines())
lines = self.con