Enable perfboot.py to install APKs before measurement.
This CL adds --apk-dir option, which specifies the directory
that contains APK files to be installed before measuring
boot time.
BUG: 22207911
Change-Id: Ifeacf34c779248686443a9ef02485272c140a456
diff --git a/init/perfboot.py b/init/perfboot.py
index 3d4940c..4c62e2a 100755
--- a/init/perfboot.py
+++ b/init/perfboot.py
@@ -40,6 +40,7 @@
import argparse
import atexit
import cStringIO
+import glob
import inspect
import logging
import math
@@ -408,9 +409,17 @@
'event tags are read. Every line contains one event '
'tag and the last event tag is used to detect that '
'the device has finished booting.')
+ parser.add_argument('--apk-dir', help='Specify the directory which contains '
+ 'APK files to be installed before measuring boot time.')
return parser.parse_args()
+def install_apks(device, apk_dir):
+ for apk in glob.glob(os.path.join(apk_dir, '*.apk')):
+ print 'Installing: ' + apk
+ device.install(apk, replace=True)
+
+
def main():
args = parse_args()
if args.verbose:
@@ -425,6 +434,9 @@
device.get_prop('ro.build.version.incremental'))
check_dm_verity_settings(device)
+ if args.apk_dir:
+ install_apks(device, args.apk_dir)
+
record_list = []
event_tags = filter_event_tags(read_event_tags(args.tags), device)
init_perf(device, args.output, record_list, event_tags)