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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 raise Exception('APK install failed unexpectedly.') | 51 raise Exception('APK install failed unexpectedly.') |
52 | 52 |
53 with open(metadata_path, 'w') as outfile: | 53 with open(metadata_path, 'w') as outfile: |
54 outfile.write(metadata) | 54 outfile.write(metadata) |
55 | 55 |
56 | 56 |
57 def main(): | 57 def main(): |
58 parser = optparse.OptionParser() | 58 parser = optparse.OptionParser() |
59 parser.add_option('--apk-path', | 59 parser.add_option('--apk-path', |
60 help='Path to .apk to install.') | 60 help='Path to .apk to install.') |
| 61 parser.add_option('--split-apk-path', |
| 62 help='Path to .apk splits (can specify multiple times, causes ' |
| 63 '--install-multiple to be used.', |
| 64 action='append') |
61 parser.add_option('--install-record', | 65 parser.add_option('--install-record', |
62 help='Path to install record (touched only when APK is installed).') | 66 help='Path to install record (touched only when APK is installed).') |
63 parser.add_option('--build-device-configuration', | 67 parser.add_option('--build-device-configuration', |
64 help='Path to build device configuration.') | 68 help='Path to build device configuration.') |
65 parser.add_option('--stamp', | 69 parser.add_option('--stamp', |
66 help='Path to touch on success.') | 70 help='Path to touch on success.') |
67 parser.add_option('--configuration-name', | 71 parser.add_option('--configuration-name', |
68 help='The build CONFIGURATION_NAME') | 72 help='The build CONFIGURATION_NAME') |
69 options, _ = parser.parse_args() | 73 options, _ = parser.parse_args() |
70 | 74 |
71 device = build_device.GetBuildDeviceFromPath( | 75 device = build_device.GetBuildDeviceFromPath( |
72 options.build_device_configuration) | 76 options.build_device_configuration) |
73 if not device: | 77 if not device: |
74 return | 78 return |
75 | 79 |
76 constants.SetBuildType(options.configuration_name) | 80 constants.SetBuildType(options.configuration_name) |
77 | 81 |
78 serial_number = device.GetSerialNumber() | 82 serial_number = device.GetSerialNumber() |
79 apk_package = apk_helper.GetPackageName(options.apk_path) | 83 apk_package = apk_helper.GetPackageName(options.apk_path) |
80 | 84 |
81 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) | 85 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) |
82 | 86 |
83 # If the APK on the device does not match the one that was last installed by | 87 # If the APK on the device does not match the one that was last installed by |
84 # the build, then the APK has to be installed (regardless of the md5 record). | 88 # the build, then the APK has to be installed (regardless of the md5 record). |
85 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) | 89 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) |
86 | 90 |
87 def Install(): | 91 def Install(): |
88 device.Install(options.apk_path, reinstall=True) | 92 # TODO: Filter splits using split-select. |
| 93 active_splits = options.split_apk_path |
| 94 if active_splits: |
| 95 device.adb.InstallMultiple( |
| 96 [options.apk_path] + active_splits, |
| 97 reinstall=True) |
| 98 else: |
| 99 device.Install(options.apk_path, reinstall=True) |
| 100 |
89 RecordInstallMetadata(device, apk_package, metadata_path) | 101 RecordInstallMetadata(device, apk_package, metadata_path) |
90 build_utils.Touch(options.install_record) | 102 build_utils.Touch(options.install_record) |
91 | 103 |
92 | 104 |
93 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) | 105 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) |
94 md5_check.CallAndRecordIfStale( | 106 md5_check.CallAndRecordIfStale( |
95 Install, | 107 Install, |
96 record_path=record_path, | 108 record_path=record_path, |
97 input_paths=[options.apk_path], | 109 input_paths=[options.apk_path], |
98 force=force_install) | 110 force=force_install) |
99 | 111 |
100 if options.stamp: | 112 if options.stamp: |
101 build_utils.Touch(options.stamp) | 113 build_utils.Touch(options.stamp) |
102 | 114 |
103 | 115 |
104 if __name__ == '__main__': | 116 if __name__ == '__main__': |
105 sys.exit(main()) | 117 sys.exit(main()) |
OLD | NEW |