| 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 |
| 11 import optparse | 11 import optparse |
| 12 import os | 12 import os |
| 13 import re | 13 import re |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 from util import build_device | 16 from util import build_device |
| 17 from util import build_utils | 17 from util import build_utils |
| 18 from util import md5_check | 18 from util import md5_check |
| 19 | 19 |
| 20 BUILD_ANDROID_DIR = os.path.abspath( | 20 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') |
| 21 os.path.join(os.path.dirname(__file__), '..')) | |
| 22 sys.path.append(BUILD_ANDROID_DIR) | 21 sys.path.append(BUILD_ANDROID_DIR) |
| 23 | 22 |
| 24 import devil_chromium | |
| 25 from devil.android import apk_helper | 23 from devil.android import apk_helper |
| 26 from pylib import constants | 24 from pylib import constants |
| 27 | 25 |
| 28 | 26 |
| 29 def GetNewMetadata(device, apk_package): | 27 def GetNewMetadata(device, apk_package): |
| 30 """Gets the metadata on the device for the apk_package apk.""" | 28 """Gets the metadata on the device for the apk_package apk.""" |
| 31 output = device.RunShellCommand('ls -l /data/app/') | 29 output = device.RunShellCommand('ls -l /data/app/') |
| 32 # Matches lines like: | 30 # Matches lines like: |
| 33 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ | 31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
| 34 # org.chromium.chrome.apk | 32 # org.chromium.chrome.apk |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 help='Path to the Android SDK build tools folder. ' + | 67 help='Path to the Android SDK build tools folder. ' + |
| 70 'Required when using --split-apk-path.') | 68 'Required when using --split-apk-path.') |
| 71 parser.add_option('--install-record', | 69 parser.add_option('--install-record', |
| 72 help='Path to install record (touched only when APK is installed).') | 70 help='Path to install record (touched only when APK is installed).') |
| 73 parser.add_option('--build-device-configuration', | 71 parser.add_option('--build-device-configuration', |
| 74 help='Path to build device configuration.') | 72 help='Path to build device configuration.') |
| 75 parser.add_option('--stamp', | 73 parser.add_option('--stamp', |
| 76 help='Path to touch on success.') | 74 help='Path to touch on success.') |
| 77 parser.add_option('--configuration-name', | 75 parser.add_option('--configuration-name', |
| 78 help='The build CONFIGURATION_NAME') | 76 help='The build CONFIGURATION_NAME') |
| 79 parser.add_option('--output-directory', | |
| 80 help='The output directory.') | |
| 81 options, _ = parser.parse_args() | 77 options, _ = parser.parse_args() |
| 82 | 78 |
| 83 constants.SetBuildType(options.configuration_name) | |
| 84 | |
| 85 devil_chromium.Initialize( | |
| 86 output_directory=os.path.abspath(options.output_directory)) | |
| 87 | |
| 88 device = build_device.GetBuildDeviceFromPath( | 79 device = build_device.GetBuildDeviceFromPath( |
| 89 options.build_device_configuration) | 80 options.build_device_configuration) |
| 90 if not device: | 81 if not device: |
| 91 return | 82 return |
| 92 | 83 |
| 84 constants.SetBuildType(options.configuration_name) |
| 85 |
| 93 serial_number = device.GetSerialNumber() | 86 serial_number = device.GetSerialNumber() |
| 94 apk_package = apk_helper.GetPackageName(options.apk_path) | 87 apk_package = apk_helper.GetPackageName(options.apk_path) |
| 95 | 88 |
| 96 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) | 89 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) |
| 97 | 90 |
| 98 # If the APK on the device does not match the one that was last installed by | 91 # If the APK on the device does not match the one that was last installed by |
| 99 # the build, then the APK has to be installed (regardless of the md5 record). | 92 # the build, then the APK has to be installed (regardless of the md5 record). |
| 100 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) | 93 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) |
| 101 | 94 |
| 102 | 95 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 record_path=record_path, | 109 record_path=record_path, |
| 117 input_paths=[options.apk_path], | 110 input_paths=[options.apk_path], |
| 118 force=force_install) | 111 force=force_install) |
| 119 | 112 |
| 120 if options.stamp: | 113 if options.stamp: |
| 121 build_utils.Touch(options.stamp) | 114 build_utils.Touch(options.stamp) |
| 122 | 115 |
| 123 | 116 |
| 124 if __name__ == '__main__': | 117 if __name__ == '__main__': |
| 125 sys.exit(main()) | 118 sys.exit(main()) |
| OLD | NEW |