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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 from pylib import constants | 23 from pylib import constants |
24 from pylib.utils import apk_helper | 24 from pylib.utils import apk_helper |
25 | 25 |
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 \ | 31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
32 # org.chromium.chrome.shell.apk | 32 # org.chromium.chrome.apk |
33 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ | 33 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
34 # org.chromium.chrome.shell-1.apk | 34 # org.chromium.chrome-1.apk |
35 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) |
36 matches = filter(apk_matcher, output) | 36 matches = filter(apk_matcher, output) |
37 return matches[0] if matches else None | 37 return matches[0] if matches else None |
38 | 38 |
39 def HasInstallMetadataChanged(device, apk_package, metadata_path): | 39 def HasInstallMetadataChanged(device, apk_package, metadata_path): |
40 """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.""" |
41 if not os.path.exists(metadata_path): | 41 if not os.path.exists(metadata_path): |
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: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 record_path=record_path, | 109 record_path=record_path, |
110 input_paths=[options.apk_path], | 110 input_paths=[options.apk_path], |
111 force=force_install) | 111 force=force_install) |
112 | 112 |
113 if options.stamp: | 113 if options.stamp: |
114 build_utils.Touch(options.stamp) | 114 build_utils.Touch(options.stamp) |
115 | 115 |
116 | 116 |
117 if __name__ == '__main__': | 117 if __name__ == '__main__': |
118 sys.exit(main()) | 118 sys.exit(main()) |
OLD | NEW |