OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Brings in Chrome Android's android_commands module, which itself is a | 5 """Brings in Chrome Android's android_commands module, which itself is a |
6 thin(ish) wrapper around adb.""" | 6 thin(ish) wrapper around adb.""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (os.path.exists(os.path.join( | 80 if (os.path.exists(os.path.join( |
81 constants.GetOutDirectory('Release'), 'md5sum_bin_host'))): | 81 constants.GetOutDirectory('Release'), 'md5sum_bin_host'))): |
82 constants.SetBuildType('Release') | 82 constants.SetBuildType('Release') |
83 elif (os.path.exists(os.path.join( | 83 elif (os.path.exists(os.path.join( |
84 constants.GetOutDirectory('Debug'), 'md5sum_bin_host'))): | 84 constants.GetOutDirectory('Debug'), 'md5sum_bin_host'))): |
85 constants.SetBuildType('Debug') | 85 constants.SetBuildType('Debug') |
86 | 86 |
87 self._device.Install(apk_path) | 87 self._device.Install(apk_path) |
88 | 88 |
89 def IsUserBuild(self): | 89 def IsUserBuild(self): |
90 return self._device.old_interface.GetBuildType() == 'user' | 90 return self._device.GetProp('ro.build.type') == 'user' |
91 | 91 |
92 | 92 |
93 def GetBuildTypeOfPath(path): | 93 def GetBuildTypeOfPath(path): |
94 if not path: | 94 if not path: |
95 return None | 95 return None |
96 for build_dir, build_type in util.GetBuildDirectories(): | 96 for build_dir, build_type in util.GetBuildDirectories(): |
97 if os.path.join(build_dir, build_type) in path: | 97 if os.path.join(build_dir, build_type) in path: |
98 return build_type | 98 return build_type |
99 return None | 99 return None |
100 | 100 |
(...skipping 13 matching lines...) Expand all Loading... |
114 ] | 114 ] |
115 | 115 |
116 host_tools = [ | 116 host_tools = [ |
117 'bitmaptools', | 117 'bitmaptools', |
118 'md5sum_bin_host', | 118 'md5sum_bin_host', |
119 ] | 119 ] |
120 | 120 |
121 if platform.GetHostPlatform().GetOSName() == 'linux': | 121 if platform.GetHostPlatform().GetOSName() == 'linux': |
122 host_tools.append('host_forwarder') | 122 host_tools.append('host_forwarder') |
123 | 123 |
124 has_device_prebuilt = adb.system_properties['ro.product.cpu.abi'].startswith( | 124 has_device_prebuilt = adb.device().GetProp('ro.product.cpu.abi').startswith( |
125 'armeabi') | 125 'armeabi') |
126 if not has_device_prebuilt: | 126 if not has_device_prebuilt: |
127 return all([support_binaries.FindLocallyBuiltPath(t) for t in device_tools]) | 127 return all([support_binaries.FindLocallyBuiltPath(t) for t in device_tools]) |
128 | 128 |
129 build_type = None | 129 build_type = None |
130 for t in device_tools + host_tools: | 130 for t in device_tools + host_tools: |
131 executable = os.path.basename(t) | 131 executable = os.path.basename(t) |
132 locally_built_path = support_binaries.FindLocallyBuiltPath(t) | 132 locally_built_path = support_binaries.FindLocallyBuiltPath(t) |
133 if not build_type: | 133 if not build_type: |
134 build_type = GetBuildTypeOfPath(locally_built_path) or 'Release' | 134 build_type = GetBuildTypeOfPath(locally_built_path) or 'Release' |
135 constants.SetBuildType(build_type) | 135 constants.SetBuildType(build_type) |
136 dest = os.path.join(constants.GetOutDirectory(), t) | 136 dest = os.path.join(constants.GetOutDirectory(), t) |
137 if not locally_built_path: | 137 if not locally_built_path: |
138 logging.info('Setting up prebuilt %s', dest) | 138 logging.info('Setting up prebuilt %s', dest) |
139 if not os.path.exists(os.path.dirname(dest)): | 139 if not os.path.exists(os.path.dirname(dest)): |
140 os.makedirs(os.path.dirname(dest)) | 140 os.makedirs(os.path.dirname(dest)) |
141 platform_name = ('android' if t in device_tools else | 141 platform_name = ('android' if t in device_tools else |
142 platform.GetHostPlatform().GetOSName()) | 142 platform.GetHostPlatform().GetOSName()) |
143 prebuilt_path = support_binaries.FindPath(executable, platform_name) | 143 prebuilt_path = support_binaries.FindPath(executable, platform_name) |
144 if not prebuilt_path or not os.path.exists(prebuilt_path): | 144 if not prebuilt_path or not os.path.exists(prebuilt_path): |
145 raise NotImplementedError(""" | 145 raise NotImplementedError(""" |
146 %s must be checked into cloud storage. | 146 %s must be checked into cloud storage. |
147 Instructions: | 147 Instructions: |
148 http://www.chromium.org/developers/telemetry/upload_to_cloud_storage | 148 http://www.chromium.org/developers/telemetry/upload_to_cloud_storage |
149 """ % t) | 149 """ % t) |
150 shutil.copyfile(prebuilt_path, dest) | 150 shutil.copyfile(prebuilt_path, dest) |
151 os.chmod(dest, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) | 151 os.chmod(dest, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) |
152 return True | 152 return True |
OLD | NEW |