Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1288993002: Revert of [Android] Remove android_commands and android_testrunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
11 import collections 11 import collections
12 import contextlib 12 import contextlib
13 import itertools 13 import itertools
14 import logging 14 import logging
15 import multiprocessing 15 import multiprocessing
16 import os 16 import os
17 import posixpath 17 import posixpath
18 import re 18 import re
19 import shutil 19 import shutil
20 import sys 20 import sys
21 import tempfile 21 import tempfile
22 import threading 22 import threading
23 import time 23 import time
24 import zipfile 24 import zipfile
25 25
26 import pylib.android_commands
26 from pylib import cmd_helper 27 from pylib import cmd_helper
27 from pylib import constants 28 from pylib import constants
28 from pylib import device_signal 29 from pylib import device_signal
29 from pylib.constants import keyevent 30 from pylib.constants import keyevent
30 from pylib.device import adb_wrapper 31 from pylib.device import adb_wrapper
31 from pylib.device import decorators 32 from pylib.device import decorators
32 from pylib.device import device_blacklist 33 from pylib.device import device_blacklist
33 from pylib.device import device_errors 34 from pylib.device import device_errors
34 from pylib.device import intent 35 from pylib.device import intent
35 from pylib.device import logcat_monitor 36 from pylib.device import logcat_monitor
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 device: Either a device serial, an existing AdbWrapper instance, or an 167 device: Either a device serial, an existing AdbWrapper instance, or an
167 an existing AndroidCommands instance. 168 an existing AndroidCommands instance.
168 default_timeout: An integer containing the default number of seconds to 169 default_timeout: An integer containing the default number of seconds to
169 wait for an operation to complete if no explicit value 170 wait for an operation to complete if no explicit value
170 is provided. 171 is provided.
171 default_retries: An integer containing the default number or times an 172 default_retries: An integer containing the default number or times an
172 operation should be retried on failure if no explicit 173 operation should be retried on failure if no explicit
173 value is provided. 174 value is provided.
174 """ 175 """
175 self.adb = None 176 self.adb = None
177 self.old_interface = None
176 if isinstance(device, basestring): 178 if isinstance(device, basestring):
177 self.adb = adb_wrapper.AdbWrapper(device) 179 self.adb = adb_wrapper.AdbWrapper(device)
180 self.old_interface = pylib.android_commands.AndroidCommands(device)
178 elif isinstance(device, adb_wrapper.AdbWrapper): 181 elif isinstance(device, adb_wrapper.AdbWrapper):
179 self.adb = device 182 self.adb = device
183 self.old_interface = pylib.android_commands.AndroidCommands(str(device))
184 elif isinstance(device, pylib.android_commands.AndroidCommands):
185 self.adb = adb_wrapper.AdbWrapper(device.GetDevice())
186 self.old_interface = device
180 else: 187 else:
181 raise ValueError('Unsupported device value: %r' % device) 188 raise ValueError('Unsupported device value: %r' % device)
182 self._commands_installed = None 189 self._commands_installed = None
183 self._default_timeout = default_timeout 190 self._default_timeout = default_timeout
184 self._default_retries = default_retries 191 self._default_retries = default_retries
185 self._cache = {} 192 self._cache = {}
186 self._client_caches = {} 193 self._client_caches = {}
187 assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR) 194 assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)
188 assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR) 195 assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR)
189 196
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices() 1889 return [cls(adb) for adb in adb_wrapper.AdbWrapper.Devices()
1883 if not blacklisted(adb)] 1890 if not blacklisted(adb)]
1884 1891
1885 @decorators.WithTimeoutAndRetriesFromInstance() 1892 @decorators.WithTimeoutAndRetriesFromInstance()
1886 def RestartAdbd(self, timeout=None, retries=None): 1893 def RestartAdbd(self, timeout=None, retries=None):
1887 logging.info('Restarting adbd on device.') 1894 logging.info('Restarting adbd on device.')
1888 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script: 1895 with device_temp_file.DeviceTempFile(self.adb, suffix='.sh') as script:
1889 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT) 1896 self.WriteFile(script.name, _RESTART_ADBD_SCRIPT)
1890 self.RunShellCommand(['source', script.name], as_root=True) 1897 self.RunShellCommand(['source', script.name], as_root=True)
1891 self.adb.WaitForDevice() 1898 self.adb.WaitForDevice()
OLDNEW
« no previous file with comments | « build/android/pylib/device/decorators_test.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698