| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Install *_incremental.apk targets as well as their dependent files.""" | 7 """Install *_incremental.apk targets as well as their dependent files.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import glob | 10 import glob |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 else: | 114 else: |
| 115 all_devices = device_utils.DeviceUtils.parallel(devices) | 115 all_devices = device_utils.DeviceUtils.parallel(devices) |
| 116 msg = ('More than one device available.\n' | 116 msg = ('More than one device available.\n' |
| 117 'Use --device=SERIAL to select a device.\n' | 117 'Use --device=SERIAL to select a device.\n' |
| 118 'Available devices:\n') | 118 'Available devices:\n') |
| 119 descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None) | 119 descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None) |
| 120 for d, desc in zip(devices, descriptions): | 120 for d, desc in zip(devices, descriptions): |
| 121 msg += ' %s (%s)\n' % (d, desc) | 121 msg += ' %s (%s)\n' % (d, desc) |
| 122 raise Exception(msg) | 122 raise Exception(msg) |
| 123 | 123 |
| 124 apk_help = apk_helper.ApkHelper(args.apk_path) | 124 apk = apk_helper.ApkHelper(args.apk_path) |
| 125 apk_package = apk_help.GetPackageName() | 125 apk_package = apk.GetPackageName() |
| 126 device_incremental_dir = '/data/local/tmp/incremental-app-%s' % apk_package | 126 device_incremental_dir = '/data/local/tmp/incremental-app-%s' % apk_package |
| 127 | 127 |
| 128 if args.uninstall: | 128 if args.uninstall: |
| 129 device.Uninstall(apk_package) | 129 device.Uninstall(apk_package) |
| 130 device.RunShellCommand(['rm', '-rf', device_incremental_dir], | 130 device.RunShellCommand(['rm', '-rf', device_incremental_dir], |
| 131 check_return=True) | 131 check_return=True) |
| 132 logging.info('Uninstall took %s seconds.', main_timer.GetDelta()) | 132 logging.info('Uninstall took %s seconds.', main_timer.GetDelta()) |
| 133 return | 133 return |
| 134 | 134 |
| 135 # Install .apk(s) if any of them have changed. | 135 # Install .apk(s) if any of them have changed. |
| 136 def do_install(): | 136 def do_install(): |
| 137 install_timer.Start() | 137 install_timer.Start() |
| 138 if args.splits: | 138 if args.splits: |
| 139 splits = [] | 139 splits = [] |
| 140 for split_glob in args.splits: | 140 for split_glob in args.splits: |
| 141 splits.extend((f for f in glob.glob(split_glob))) | 141 splits.extend((f for f in glob.glob(split_glob))) |
| 142 device.InstallSplitApk(args.apk_path, splits, reinstall=True, | 142 device.InstallSplitApk(apk, splits, reinstall=True, |
| 143 allow_cached_props=True, permissions=()) | 143 allow_cached_props=True, permissions=()) |
| 144 else: | 144 else: |
| 145 device.Install(args.apk_path, reinstall=True, permissions=()) | 145 device.Install(apk, reinstall=True, permissions=()) |
| 146 install_timer.Stop(log=False) | 146 install_timer.Stop(log=False) |
| 147 | 147 |
| 148 # Push .so and .dex files to the device (if they have changed). | 148 # Push .so and .dex files to the device (if they have changed). |
| 149 def do_push_files(): | 149 def do_push_files(): |
| 150 if args.lib_dir: | 150 if args.lib_dir: |
| 151 push_native_timer.Start() | 151 push_native_timer.Start() |
| 152 device_lib_dir = posixpath.join(device_incremental_dir, 'lib') | 152 device_lib_dir = posixpath.join(device_incremental_dir, 'lib') |
| 153 device.PushChangedFiles([(args.lib_dir, device_lib_dir)], | 153 device.PushChangedFiles([(args.lib_dir, device_lib_dir)], |
| 154 delete_device_stale=True) | 154 delete_device_stale=True) |
| 155 push_native_timer.Stop(log=False) | 155 push_native_timer.Stop(log=False) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 166 shutil.copyfile(src_path, os.path.join(temp_dir, dest_name)) | 166 shutil.copyfile(src_path, os.path.join(temp_dir, dest_name)) |
| 167 device.PushChangedFiles([(temp_dir, device_dex_dir)], | 167 device.PushChangedFiles([(temp_dir, device_dex_dir)], |
| 168 delete_device_stale=True) | 168 delete_device_stale=True) |
| 169 push_dex_timer.Stop(log=False) | 169 push_dex_timer.Stop(log=False) |
| 170 | 170 |
| 171 def check_selinux(): | 171 def check_selinux(): |
| 172 # Samsung started using SELinux before Marshmallow. There may be even more | 172 # Samsung started using SELinux before Marshmallow. There may be even more |
| 173 # cases where this is required... | 173 # cases where this is required... |
| 174 has_selinux = (device.build_version_sdk >= version_codes.MARSHMALLOW or | 174 has_selinux = (device.build_version_sdk >= version_codes.MARSHMALLOW or |
| 175 device.GetProp('selinux.policy_version')) | 175 device.GetProp('selinux.policy_version')) |
| 176 if has_selinux and apk_help.HasIsolatedProcesses(): | 176 if has_selinux and apk.HasIsolatedProcesses(): |
| 177 raise Exception('Cannot use incremental installs on versions of Android ' | 177 raise Exception('Cannot use incremental installs on versions of Android ' |
| 178 'where isoloated processes cannot access the filesystem ' | 178 'where isoloated processes cannot access the filesystem ' |
| 179 '(this includes Android M+, and Samsung L+) without ' | 179 '(this includes Android M+, and Samsung L+) without ' |
| 180 'first disabling isoloated processes.\n' | 180 'first disabling isoloated processes.\n' |
| 181 'To do so, use GN arg:\n' | 181 'To do so, use GN arg:\n' |
| 182 ' disable_incremental_isolated_processes=true') | 182 ' disable_incremental_isolated_processes=true') |
| 183 | 183 |
| 184 cache_path = '%s/files-cache.json' % device_incremental_dir | 184 cache_path = '%s/files-cache.json' % device_incremental_dir |
| 185 def restore_cache(): | 185 def restore_cache(): |
| 186 if not args.cache: | 186 if not args.cache: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 logging.info( | 228 logging.info( |
| 229 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)', | 229 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)', |
| 230 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(), | 230 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(), |
| 231 push_native_timer.GetDelta(), push_dex_timer.GetDelta(), | 231 push_native_timer.GetDelta(), push_dex_timer.GetDelta(), |
| 232 finalize_timer.GetDelta()) | 232 finalize_timer.GetDelta()) |
| 233 | 233 |
| 234 | 234 |
| 235 if __name__ == '__main__': | 235 if __name__ == '__main__': |
| 236 sys.exit(main()) | 236 sys.exit(main()) |
| 237 | 237 |
| OLD | NEW |