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