Example #1
0
def getLaunchTime(apk_name,profile):
	apk_folder = Constant.apk_path + apk_name
	manifest = apk_folder + "\\" + apk_name  +"\\AndroidManifest.xml"
	print manifest
	if not os.path.exists(manifest):		
		decompile(apk_name)
	apko = ApkOpearate(apk_name,apk_folder)  

	package = apko.getPackage()
	main = apko.getMain()
	print "MainActivity is "+ main 
	
	os.system('adb shell am force-stop '+package)
	os.system('adb shell am  start -n' +package+'/'+main)
	
	start=datetime.now()
	end = start 
	
	p = os.popen('adb shell dumpsys activity | findstr "mFocusedActivity"')
	res = loadRes = p.read()

	while loadRes == res:
		p = os.popen('adb shell dumpsys activity | findstr "mFocusedActivity"')
		res = p.read()
		end=datetime.now()
		if (end - start).seconds >10:
			print 'No splash Activity'
			end = start 
			break
			
	f=open(profile,'a')
	#f.write("\n")
	f.write("[#application launch time --more than splash time]\n")

	if start == end:
		print "sleeptime 1000" 
		f.write("sleeptime:1000\n")
	else:
		gap = (end - start).seconds * 1000
		print "sleeptime " +str(gap) 
		f.write("sleeptime:"+str(gap)+'\n')
	f.close()
Example #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
from ApkOpearate import *
from Calculator import *
from common.constant import *

if __name__ == '__main__':

    apk_name = sys.argv[1]
    apk_folder = Constant.apk_path + apk_name
    apk_path = apk_folder + "\\" + apk_name
    apk_info_path = Constant.file_path + apk_name + "\\"

    apko = ApkOpearate(apk_name, apk_folder)
    apko.get_methods()
    package = apko.getPackage()
    main = apko.getMain()

    instrument_log = apk_info_path + Constant.info_path + Constant.instrument_log
    instrument_log_this = apk_info_path + Constant.info_path + Constant.instrument_log_this
    instrument_log_this_target = apk_info_path + Constant.info_path + Constant.instrument_log_this_target

    cal = Calculator(apk_name, instrument_log_this, package.replace('.', '/'))
    cal.filterInstrumentLog(instrument_log, instrument_log_this)
    cal.filterTestInstrumentLog(instrument_log_this,
                                instrument_log_this_target)

    cal.getCoverage()
Example #3
0
    removeFile(instrument_log)
    removeFile(instrument_log_this)
    removeFile(instrument_log_this_target)

    removeFile(re_auto_file)
    removeFile(re_stake_file)
    removeFile(re_calculate_file)

    #write file about package and classname
    apko = ApkOpearate(apk_name, apk_folder)
    apko.get_methods()

    acts = apko.getAct()
    package = apko.getPackage()  #package name of app under testing
    main = apko.getMain()  #main activity name of app under testing

    print "push file to phone"
    os.system("adb push " + name_file + " sdcard/getName.txt")
    os.system("adb push " + manifestStartFlagFile +
              " sdcard/manifestStartFlag.txt")
    os.system("adb push " + profile + " sdcard/profile.txt")
    os.system("adb push " + EditTextFile + " sdcard/EditTextFile.txt")

    print "start exploration\n"

    print "adb shell am instrument -e class " + package + ".test." + Constant.bfs_preparefile + " -w " + package + ".test/android.test.InstrumentationTestRunner >>" + Constant.re_auto_file
    command = "adb shell am instrument -e class " + package + ".test." + Constant.bfs_preparefile + " -w " + package + ".test/android.test.InstrumentationTestRunner"
    os.system("echo " + command)
    os.system(command)