OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 """Installs an APK. | 7 """Installs an APK. |
8 | 8 |
9 """ | 9 """ |
10 | 10 |
11 import optparse | 11 import optparse |
12 import os | 12 import os |
13 import re | 13 import re |
14 import sys | 14 import sys |
15 | 15 |
16 from util import build_device | 16 from util import build_device |
17 from util import build_utils | 17 from util import build_utils |
18 from util import md5_check | 18 from util import md5_check |
19 | 19 |
20 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | 20 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
21 sys.path.append(BUILD_ANDROID_DIR) | 21 sys.path.append(BUILD_ANDROID_DIR) |
22 | 22 |
| 23 import devil_chromium |
23 from devil.android import apk_helper | 24 from devil.android import apk_helper |
24 from pylib import constants | 25 from pylib import constants |
25 | 26 |
26 | 27 |
27 def GetNewMetadata(device, apk_package): | 28 def GetNewMetadata(device, apk_package): |
28 """Gets the metadata on the device for the apk_package apk.""" | 29 """Gets the metadata on the device for the apk_package apk.""" |
29 output = device.RunShellCommand('ls -l /data/app/') | 30 output = device.RunShellCommand('ls -l /data/app/') |
30 # Matches lines like: | 31 # Matches lines like: |
31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ | 32 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
32 # org.chromium.chrome.apk | 33 # org.chromium.chrome.apk |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 help='Path to the Android SDK build tools folder. ' + | 68 help='Path to the Android SDK build tools folder. ' + |
68 'Required when using --split-apk-path.') | 69 'Required when using --split-apk-path.') |
69 parser.add_option('--install-record', | 70 parser.add_option('--install-record', |
70 help='Path to install record (touched only when APK is installed).') | 71 help='Path to install record (touched only when APK is installed).') |
71 parser.add_option('--build-device-configuration', | 72 parser.add_option('--build-device-configuration', |
72 help='Path to build device configuration.') | 73 help='Path to build device configuration.') |
73 parser.add_option('--stamp', | 74 parser.add_option('--stamp', |
74 help='Path to touch on success.') | 75 help='Path to touch on success.') |
75 parser.add_option('--configuration-name', | 76 parser.add_option('--configuration-name', |
76 help='The build CONFIGURATION_NAME') | 77 help='The build CONFIGURATION_NAME') |
| 78 parser.add_option('--output-directory', |
| 79 help='The output directory.') |
77 options, _ = parser.parse_args() | 80 options, _ = parser.parse_args() |
78 | 81 |
| 82 constants.SetBuildType(options.configuration_name) |
| 83 |
| 84 devil_chromium.Initialize( |
| 85 output_directory=os.path.abspath(options.output_directory)) |
| 86 |
79 device = build_device.GetBuildDeviceFromPath( | 87 device = build_device.GetBuildDeviceFromPath( |
80 options.build_device_configuration) | 88 options.build_device_configuration) |
81 if not device: | 89 if not device: |
82 return | 90 return |
83 | 91 |
84 constants.SetBuildType(options.configuration_name) | |
85 | |
86 serial_number = device.GetSerialNumber() | 92 serial_number = device.GetSerialNumber() |
87 apk_package = apk_helper.GetPackageName(options.apk_path) | 93 apk_package = apk_helper.GetPackageName(options.apk_path) |
88 | 94 |
89 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) | 95 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) |
90 | 96 |
91 # If the APK on the device does not match the one that was last installed by | 97 # If the APK on the device does not match the one that was last installed by |
92 # the build, then the APK has to be installed (regardless of the md5 record). | 98 # the build, then the APK has to be installed (regardless of the md5 record). |
93 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) | 99 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) |
94 | 100 |
95 | 101 |
(...skipping 13 matching lines...) Expand all Loading... |
109 record_path=record_path, | 115 record_path=record_path, |
110 input_paths=[options.apk_path], | 116 input_paths=[options.apk_path], |
111 force=force_install) | 117 force=force_install) |
112 | 118 |
113 if options.stamp: | 119 if options.stamp: |
114 build_utils.Touch(options.stamp) | 120 build_utils.Touch(options.stamp) |
115 | 121 |
116 | 122 |
117 if __name__ == '__main__': | 123 if __name__ == '__main__': |
118 sys.exit(main()) | 124 sys.exit(main()) |
OLD | NEW |