Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: build/android/incremental_install/installer.py

Issue 1385943002: GN: Don't attempt incremental install with sandboxes on some samsung devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@device-utils-caching
Patch Set: nits Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 with build_utils.TempDir() as temp_dir: 155 with build_utils.TempDir() as temp_dir:
156 device_dex_dir = posixpath.join(device_incremental_dir, 'dex') 156 device_dex_dir = posixpath.join(device_incremental_dir, 'dex')
157 # Ensure no two files have the same name. 157 # Ensure no two files have the same name.
158 transformed_names = _TransformDexPaths(args.dex_files) 158 transformed_names = _TransformDexPaths(args.dex_files)
159 for src_path, dest_name in zip(args.dex_files, transformed_names): 159 for src_path, dest_name in zip(args.dex_files, transformed_names):
160 shutil.copyfile(src_path, os.path.join(temp_dir, dest_name)) 160 shutil.copyfile(src_path, os.path.join(temp_dir, dest_name))
161 device.PushChangedFiles([(temp_dir, device_dex_dir)], 161 device.PushChangedFiles([(temp_dir, device_dex_dir)],
162 delete_device_stale=True) 162 delete_device_stale=True)
163 push_dex_timer.Stop(log=False) 163 push_dex_timer.Stop(log=False)
164 164
165 def check_sdk_version(): 165 def check_selinux():
166 if device.build_version_sdk >= version_codes.MARSHMALLOW: 166 # Samsung started using SELinux before Marshmallow. There may be even more
167 if apk_help.HasIsolatedProcesses(): 167 # cases where this is required...
168 raise Exception('Cannot use perform incremental installs on Android M+ ' 168 has_selinux = (device.build_version_sdk >= version_codes.MARSHMALLOW or
169 'without first disabling isolated processes.\n' 169 device.GetProp('selinux.policy_version'))
170 'To do so, use GN arg:\n' 170 if has_selinux and apk_help.HasIsolatedProcesses():
171 ' disable_incremental_isolated_processes=true') 171 raise Exception('Cannot use incremental installs on versions of Android '
172 'where isoloated processes cannot access the filesystem '
173 '(this includes Android M+, and Samsung L+) without '
174 'first disabling isoloated processes.\n'
175 'To do so, use GN arg:\n'
176 ' disable_incremental_isolated_processes=true')
172 177
173 cache_path = '%s/files-cache.json' % device_incremental_dir 178 cache_path = '%s/files-cache.json' % device_incremental_dir
174 def restore_cache(): 179 def restore_cache():
175 # Delete the cached file so that any exceptions cause the next attempt 180 # Delete the cached file so that any exceptions cause the next attempt
176 # to re-compute md5s. 181 # to re-compute md5s.
177 cmd = 'P=%s;cat $P 2>/dev/null && rm $P' % cache_path 182 cmd = 'P=%s;cat $P 2>/dev/null && rm $P' % cache_path
178 lines = device.RunShellCommand(cmd, check_return=False, large_output=True) 183 lines = device.RunShellCommand(cmd, check_return=False, large_output=True)
179 if lines: 184 if lines:
180 device.LoadCacheData(lines[0]) 185 device.LoadCacheData(lines[0])
181 else: 186 else:
(...skipping 16 matching lines...) Expand all
198 203
199 # The firstrun.lock is released by the app itself. 204 # The firstrun.lock is released by the app itself.
200 def release_installer_lock(): 205 def release_installer_lock():
201 device.RunShellCommand('echo > %s/install.lock' % device_incremental_dir, 206 device.RunShellCommand('echo > %s/install.lock' % device_incremental_dir,
202 check_return=True) 207 check_return=True)
203 208
204 # Concurrency here speeds things up quite a bit, but DeviceUtils hasn't 209 # Concurrency here speeds things up quite a bit, but DeviceUtils hasn't
205 # been designed for multi-threading. Enabling only because this is a 210 # been designed for multi-threading. Enabling only because this is a
206 # developer-only tool. 211 # developer-only tool.
207 setup_timer = _Execute( 212 setup_timer = _Execute(
208 args.threading, create_lock_files, restore_cache, check_sdk_version) 213 args.threading, create_lock_files, restore_cache, check_selinux)
209 214
210 _Execute(args.threading, do_install, do_push_files) 215 _Execute(args.threading, do_install, do_push_files)
211 216
212 finalize_timer = _Execute(args.threading, release_installer_lock, save_cache) 217 finalize_timer = _Execute(args.threading, release_installer_lock, save_cache)
213 218
214 logging.info( 219 logging.info(
215 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)', 220 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)',
216 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(), 221 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(),
217 push_native_timer.GetDelta(), push_dex_timer.GetDelta(), 222 push_native_timer.GetDelta(), push_dex_timer.GetDelta(),
218 finalize_timer.GetDelta()) 223 finalize_timer.GetDelta())
219 224
220 225
221 if __name__ == '__main__': 226 if __name__ == '__main__':
222 sys.exit(main()) 227 sys.exit(main())
223 228
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698