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

Side by Side Diff: build/android/managed_install.py

Issue 1291793007: GN(android): Add scripts & runtime logic for installing _managed apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-managed-install
Patch Set: Created 5 years, 4 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6
7 """Install *_managed.apk targets as well as their dependent files."""
8
9 import argparse
10 import glob
11 import logging
12 import os
13 import sys
14
15 from pylib import constants
16 from pylib.device import device_errors
17 from pylib.device import device_utils
18 from pylib.utils import apk_helper
19
20
21 def main():
22 logging.basicConfig(level=logging.INFO,
23 format='%(asctime)s %(message)s')
24 parser = argparse.ArgumentParser()
25
26 parser.add_argument('apk_path',
27 help='The path to the APK to install.',
28 )
29 parser.add_argument('--split',
30 action='append',
31 dest='splits',
32 help='A glob matching the apk splits. '
33 'Can be specified multiple times.')
34 parser.add_argument('--lib-dir',
35 help='Path to native libraries directory.')
36 parser.add_argument('-d', '--device', dest='device',
37 help='Target device for apk to install on.')
38
39 args = parser.parse_args()
40
41 constants.SetBuildType('Debug')
42 devices = device_utils.DeviceUtils.HealthyDevices()
43
44 if args.device:
45 devices = [d for d in devices if d == args.device]
46 if not devices:
47 raise device_errors.DeviceUnreachableError(args.device)
48 elif not devices:
49 raise device_errors.NoDevicesError()
50 elif len(devices) > 1:
51 raise Exception('More than one device available.\n'
52 'Use --device=SERIAL to select a device.')
53 device = devices[0]
54
55 # Install .apk(s) if any of them have changed.apk
56 logging.info('Installing .apk')
57 if args.splits:
58 splits = []
59 for split_glob in args.splits:
60 splits.extend((f for f in glob.glob(split_glob)))
61 device.InstallSplitApk(args.apk_path, splits, reinstall=True, retries=0)
62 else:
63 device.Install(args.apk_path, reinstall=True, retries=0)
64
65 # Push .so files to the device (if they have changed).
66 if args.lib_dir:
67 logging.info('Pushing libraries')
68 apk_package = apk_helper.ApkHelper(args.apk_path).GetPackageName()
69 device_lib_dir = '/data/local/tmp/managed-app-%s/lib' % apk_package
70 device.PushChangedFiles([(args.lib_dir, device_lib_dir)],
71 delete_device_stale=True)
72
73
74 if __name__ == '__main__':
75 sys.exit(main())
76
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698