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 10 matching lines...) Expand all Loading... |
21 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | 21 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
22 sys.path.append(BUILD_ANDROID_DIR) | 22 sys.path.append(BUILD_ANDROID_DIR) |
23 | 23 |
24 from pylib import constants | 24 from pylib import constants |
25 from pylib.utils import apk_helper | 25 from pylib.utils import apk_helper |
26 | 26 |
27 def GetNewMetadata(device, apk_package): | 27 def GetNewMetadata(device, apk_package): |
28 """Gets the metadata on the device for the apk_package apk.""" | 28 """Gets the metadata on the device for the apk_package apk.""" |
29 output = device.RunShellCommand('ls -l /data/app/') | 29 output = device.RunShellCommand('ls -l /data/app/') |
30 # Matches lines like: | 30 # Matches lines like: |
31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t
estshell.apk | 31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
32 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t
estshell-1.apk | 32 # org.chromium.chrome.shell.apk |
| 33 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
| 34 # org.chromium.chrome.shell-1.apk |
33 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) | 35 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) |
34 matches = filter(apk_matcher, output) | 36 matches = filter(apk_matcher, output) |
35 return matches[0] if matches else None | 37 return matches[0] if matches else None |
36 | 38 |
37 def HasInstallMetadataChanged(device, apk_package, metadata_path): | 39 def HasInstallMetadataChanged(device, apk_package, metadata_path): |
38 """Checks if the metadata on the device for apk_package has changed.""" | 40 """Checks if the metadata on the device for apk_package has changed.""" |
39 if not os.path.exists(metadata_path): | 41 if not os.path.exists(metadata_path): |
40 return True | 42 return True |
41 | 43 |
42 with open(metadata_path, 'r') as expected_file: | 44 with open(metadata_path, 'r') as expected_file: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 record_path=record_path, | 97 record_path=record_path, |
96 input_paths=[options.apk_path], | 98 input_paths=[options.apk_path], |
97 force=force_install) | 99 force=force_install) |
98 | 100 |
99 if options.stamp: | 101 if options.stamp: |
100 build_utils.Touch(options.stamp) | 102 build_utils.Touch(options.stamp) |
101 | 103 |
102 | 104 |
103 if __name__ == '__main__': | 105 if __name__ == '__main__': |
104 sys.exit(main(sys.argv)) | 106 sys.exit(main(sys.argv)) |
OLD | NEW |