OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 | 5 |
6 import android_devices | 6 import android_devices |
7 import config | 7 import config |
8 import copy | 8 import copy |
9 import default_flavor | 9 import default_flavor |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 'No device found for builder: %s' % str(builder_dict)) # pragma: no cover | 39 'No device found for builder: %s' % str(builder_dict)) # pragma: no cover |
40 | 40 |
41 | 41 |
42 class _ADBWrapper(object): | 42 class _ADBWrapper(object): |
43 """Wrapper for the ADB recipe module. | 43 """Wrapper for the ADB recipe module. |
44 | 44 |
45 The ADB recipe module looks for the ADB binary at a path we don't have checked | 45 The ADB recipe module looks for the ADB binary at a path we don't have checked |
46 out on our bots. This wrapper ensures that we set a custom ADB path before | 46 out on our bots. This wrapper ensures that we set a custom ADB path before |
47 attempting to use the module. | 47 attempting to use the module. |
48 """ | 48 """ |
49 def __init__(self, adb_api, path_to_adb, serial): | 49 def __init__(self, adb_api, path_to_adb, serial, android_flavor): |
50 self._adb = adb_api | 50 self._adb = adb_api |
51 self._adb.set_adb_path(path_to_adb) | 51 self._adb.set_adb_path(path_to_adb) |
52 self._serial = serial | 52 self._serial = serial |
53 self._wait_count = 0 | 53 self._wait_count = 0 |
| 54 self._android_flavor = android_flavor |
54 | 55 |
55 def wait_for_device(self): | 56 def wait_for_device(self): |
56 """Run 'adb wait-for-device'.""" | 57 """Run 'adb wait-for-device'.""" |
57 self._wait_count += 1 | 58 self._wait_count += 1 |
58 self._adb(name='wait for device (%d)' % self._wait_count, | 59 cmd = [ |
59 serial=self._serial, | 60 self._android_flavor.android_bin.join('adb_wait_for_device'), |
60 cmd=['wait-for-device'], | 61 '-s', self._serial, |
61 infra_step=True) | 62 ] |
| 63 self._android_flavor._skia_api.m.step( |
| 64 name='wait for device (%d)' % self._wait_count, |
| 65 cmd=cmd, |
| 66 infra_step=True) |
62 | 67 |
63 def maybe_wait_for_device(self): | 68 def maybe_wait_for_device(self): |
64 """Run 'adb wait-for-device' if it hasn't already been run.""" | 69 """Run 'adb wait-for-device' if it hasn't already been run.""" |
65 if self._wait_count == 0: | 70 if self._wait_count == 0: |
66 self.wait_for_device() | 71 self.wait_for_device() |
67 | 72 |
68 def __call__(self, *args, **kwargs): | 73 def __call__(self, *args, **kwargs): |
69 self.maybe_wait_for_device() | 74 self.maybe_wait_for_device() |
70 return self._adb(*args, **kwargs) | 75 return self._adb(*args, **kwargs) |
71 | 76 |
72 | 77 |
73 class AndroidFlavorUtils(default_flavor.DefaultFlavorUtils): | 78 class AndroidFlavorUtils(default_flavor.DefaultFlavorUtils): |
74 def __init__(self, skia_api): | 79 def __init__(self, skia_api): |
75 super(AndroidFlavorUtils, self).__init__(skia_api) | 80 super(AndroidFlavorUtils, self).__init__(skia_api) |
76 self.device = device_from_builder_dict(self._skia_api.c.builder_cfg) | 81 self.device = device_from_builder_dict(self._skia_api.c.builder_cfg) |
77 slave_info = android_devices.SLAVE_INFO.get( | 82 slave_info = android_devices.SLAVE_INFO.get( |
78 self._skia_api.c.SLAVE_NAME, | 83 self._skia_api.c.SLAVE_NAME, |
79 android_devices.SLAVE_INFO['default']) | 84 android_devices.SLAVE_INFO['default']) |
80 self.serial = slave_info.serial | 85 self.serial = slave_info.serial |
81 self.android_bin = self._skia_api.m.path['slave_build'].join( | 86 self.android_bin = self._skia_api.m.path['slave_build'].join( |
82 'skia', 'platform_tools', 'android', 'bin') | 87 'skia', 'platform_tools', 'android', 'bin') |
83 self._android_sdk_root = slave_info.android_sdk_root | 88 self._android_sdk_root = slave_info.android_sdk_root |
84 self._adb = _ADBWrapper( | 89 self._adb = _ADBWrapper( |
85 self._skia_api.m.adb, | 90 self._skia_api.m.adb, |
86 self._skia_api.m.path.join(self._android_sdk_root, | 91 self._skia_api.m.path.join(self._android_sdk_root, |
87 'platform-tools', 'adb'), | 92 'platform-tools', 'adb'), |
88 self.serial) | 93 self.serial, |
| 94 self) |
89 self._has_root = slave_info.has_root | 95 self._has_root = slave_info.has_root |
90 self._default_env = {'ANDROID_SDK_ROOT': self._android_sdk_root, | 96 self._default_env = {'ANDROID_SDK_ROOT': self._android_sdk_root, |
91 'SKIA_ANDROID_VERBOSE_SETUP': 1} | 97 'SKIA_ANDROID_VERBOSE_SETUP': 1} |
92 | 98 |
93 def step(self, name, cmd, **kwargs): | 99 def step(self, name, cmd, **kwargs): |
94 self._adb.maybe_wait_for_device() | 100 self._adb.maybe_wait_for_device() |
95 args = [self.android_bin.join('android_run_skia'), | 101 args = [self.android_bin.join('android_run_skia'), |
96 '--verbose', | 102 '--verbose', |
97 '--logcat', | 103 '--logcat', |
98 '-d', self.device, | 104 '-d', self.device, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 prefix = self.device_path_join(device_scratch_dir, 'skiabot', 'skia_') | 258 prefix = self.device_path_join(device_scratch_dir, 'skiabot', 'skia_') |
253 return default_flavor.DeviceDirs( | 259 return default_flavor.DeviceDirs( |
254 dm_dir=prefix + 'dm', | 260 dm_dir=prefix + 'dm', |
255 perf_data_dir=prefix + 'perf', | 261 perf_data_dir=prefix + 'perf', |
256 resource_dir=prefix + 'resources', | 262 resource_dir=prefix + 'resources', |
257 images_dir=prefix + 'images', | 263 images_dir=prefix + 'images', |
258 skp_dirs=default_flavor.SKPDirs( | 264 skp_dirs=default_flavor.SKPDirs( |
259 prefix + 'skp', self._skia_api.c.BUILDER_NAME, '/'), | 265 prefix + 'skp', self._skia_api.c.BUILDER_NAME, '/'), |
260 tmp_dir=prefix + 'tmp_dir') | 266 tmp_dir=prefix + 'tmp_dir') |
261 | 267 |
OLD | NEW |