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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return True | 42 return True |
43 | 43 |
44 with open(metadata_path, 'r') as expected_file: | 44 with open(metadata_path, 'r') as expected_file: |
45 return expected_file.read() != GetMetadata(apk_package) | 45 return expected_file.read() != GetMetadata(apk_package) |
46 | 46 |
47 | 47 |
48 def RecordInstallMetadata(apk_package, metadata_path): | 48 def RecordInstallMetadata(apk_package, metadata_path): |
49 """Records the metadata from the device for apk_package.""" | 49 """Records the metadata from the device for apk_package.""" |
50 metadata = GetMetadata(apk_package) | 50 metadata = GetMetadata(apk_package) |
51 if not metadata: | 51 if not metadata: |
52 raise 'APK install failed unexpectedly.' | 52 if not android_commands.AndroidCommands().IsRootEnabled(): |
| 53 raise Exception('APK install failed unexpectedly -- root not enabled on ' |
| 54 'the device (run adb root).') |
| 55 raise Exception('APK install failed unexpectedly.') |
53 | 56 |
54 with open(metadata_path, 'w') as outfile: | 57 with open(metadata_path, 'w') as outfile: |
55 outfile.write(metadata) | 58 outfile.write(metadata) |
56 | 59 |
57 | 60 |
58 def main(argv): | 61 def main(argv): |
59 if not build_utils.IsDeviceReady(): | 62 if not build_utils.IsDeviceReady(): |
60 build_utils.PrintBigWarning( | 63 build_utils.PrintBigWarning( |
61 'Zero (or multiple) devices attached. Skipping APK install.') | 64 'Zero (or multiple) devices attached. Skipping APK install.') |
62 return | 65 return |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 input_paths=[options.apk_path], | 103 input_paths=[options.apk_path], |
101 input_strings=install_cmd, | 104 input_strings=install_cmd, |
102 force=force_install) | 105 force=force_install) |
103 | 106 |
104 if options.stamp: | 107 if options.stamp: |
105 build_utils.Touch(options.stamp) | 108 build_utils.Touch(options.stamp) |
106 | 109 |
107 | 110 |
108 if __name__ == '__main__': | 111 if __name__ == '__main__': |
109 sys.exit(main(sys.argv)) | 112 sys.exit(main(sys.argv)) |
OLD | NEW |