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 device.Install(options.apk_path, reinstall=True, split_paths=active_splits) | |
jbudorick
2015/05/13 15:15:42
Why should we do this instead of just installing e
agrieve
2015/05/13 15:47:46
I'm guessing you're question is about using "adb i
jbudorick
2015/05/13 15:49:14
Yeah, that was the question. Sorry, should've phra
agrieve1
2015/05/13 17:22:04
I'm guessing you're question is about using "adb i
| |
95 | |
89 RecordInstallMetadata(device, apk_package, metadata_path) | 96 RecordInstallMetadata(device, apk_package, metadata_path) |
90 build_utils.Touch(options.install_record) | 97 build_utils.Touch(options.install_record) |
91 | 98 |
92 | 99 |
93 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) | 100 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) |
94 md5_check.CallAndRecordIfStale( | 101 md5_check.CallAndRecordIfStale( |
95 Install, | 102 Install, |
96 record_path=record_path, | 103 record_path=record_path, |
97 input_paths=[options.apk_path], | 104 input_paths=[options.apk_path], |
98 force=force_install) | 105 force=force_install) |
99 | 106 |
100 if options.stamp: | 107 if options.stamp: |
101 build_utils.Touch(options.stamp) | 108 build_utils.Touch(options.stamp) |
102 | 109 |
103 | 110 |
104 if __name__ == '__main__': | 111 if __name__ == '__main__': |
105 sys.exit(main()) | 112 sys.exit(main()) |
OLD | NEW |