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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: build/android/managed_install.py
diff --git a/build/android/managed_install.py b/build/android/managed_install.py
new file mode 100755
index 0000000000000000000000000000000000000000..553374db81e07abb8a5646c7a57f24ff3984373a
--- /dev/null
+++ b/build/android/managed_install.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+#
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Install *_managed.apk targets as well as their dependent files."""
+
+import argparse
+import glob
+import logging
+import os
+import sys
+
+from pylib import constants
+from pylib.device import device_errors
+from pylib.device import device_utils
+from pylib.utils import apk_helper
+
+
+def main():
+ logging.basicConfig(level=logging.INFO,
+ format='%(asctime)s %(message)s')
+ parser = argparse.ArgumentParser()
+
+ parser.add_argument('apk_path',
+ help='The path to the APK to install.',
+ )
+ parser.add_argument('--split',
+ action='append',
+ dest='splits',
+ help='A glob matching the apk splits. '
+ 'Can be specified multiple times.')
+ parser.add_argument('--lib-dir',
+ help='Path to native libraries directory.')
+ parser.add_argument('-d', '--device', dest='device',
+ help='Target device for apk to install on.')
+
+ args = parser.parse_args()
+
+ constants.SetBuildType('Debug')
+ devices = device_utils.DeviceUtils.HealthyDevices()
+
+ if args.device:
+ devices = [d for d in devices if d == args.device]
+ if not devices:
+ raise device_errors.DeviceUnreachableError(args.device)
+ elif not devices:
+ raise device_errors.NoDevicesError()
+ elif len(devices) > 1:
+ raise Exception('More than one device available.\n'
+ 'Use --device=SERIAL to select a device.')
+ device = devices[0]
+
+ # Install .apk(s) if any of them have changed.apk
+ logging.info('Installing .apk')
+ if args.splits:
+ splits = []
+ for split_glob in args.splits:
+ splits.extend((f for f in glob.glob(split_glob)))
+ device.InstallSplitApk(args.apk_path, splits, reinstall=True, retries=0)
+ else:
+ device.Install(args.apk_path, reinstall=True, retries=0)
+
+ # Push .so files to the device (if they have changed).
+ if args.lib_dir:
+ logging.info('Pushing libraries')
+ apk_package = apk_helper.ApkHelper(args.apk_path).GetPackageName()
+ device_lib_dir = '/data/local/tmp/managed-app-%s/lib' % apk_package
+ device.PushChangedFiles([(args.lib_dir, device_lib_dir)],
+ delete_device_stale=True)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
+

Powered by Google App Engine
This is Rietveld 408576698