diff options
author | jbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 18:59:30 +0000 |
---|---|---|
committer | jbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 18:59:30 +0000 |
commit | f0f4b9730e547189baa999f657179d3756297d0c (patch) | |
tree | 2c7ab002938b40f6650d9d1cee573642dcd66b37 /build | |
parent | 4c0bb96313936a342a73705c64b6b929abd5c185 (diff) | |
download | chromium_src-f0f4b9730e547189baa999f657179d3756297d0c.zip chromium_src-f0f4b9730e547189baa999f657179d3756297d0c.tar.gz chromium_src-f0f4b9730e547189baa999f657179d3756297d0c.tar.bz2 |
[Android] Switch to DeviceUtils version of RunShellCommand.
BUG=267773
Review URL: https://codereview.chromium.org/333933003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
23 files changed, 137 insertions, 79 deletions
diff --git a/build/android/enable_asserts.py b/build/android/enable_asserts.py index 34f8e3c..8dd44f1 100755 --- a/build/android/enable_asserts.py +++ b/build/android/enable_asserts.py @@ -30,8 +30,8 @@ def main(argv): if device.old_interface.SetJavaAssertsEnabled(options.set_asserts): # TODO(jbudorick) How to best do shell restarts after the # android_commands refactor? - device.old_interface.RunShellCommand('stop') - device.old_interface.RunShellCommand('start') + device.RunShellCommand('stop') + device.RunShellCommand('start') if __name__ == '__main__': diff --git a/build/android/gyp/util/build_device.py b/build/android/gyp/util/build_device.py index 8d694c1..a5b0dd5 100644 --- a/build/android/gyp/util/build_device.py +++ b/build/android/gyp/util/build_device.py @@ -31,7 +31,7 @@ class BuildDevice(object): self.device = device_utils.DeviceUtils(self.id) def RunShellCommand(self, *args, **kwargs): - return self.device.old_interface.RunShellCommand(*args, **kwargs) + return self.device.RunShellCommand(*args, **kwargs) def PushIfNeeded(self, *args, **kwargs): return self.device.old_interface.PushIfNeeded(*args, **kwargs) @@ -61,7 +61,7 @@ def GetConfigurationForDevice(device_id): is_online = device.IsOnline() if is_online: cmd = 'ls -l /data/app; getprop ro.build.description' - cmd_output = device.old_interface.RunShellCommand(cmd) + cmd_output = device.RunShellCommand(cmd) has_root = not 'Permission denied' in cmd_output[0] if not has_root: # Disable warning log messages from EnableRoot() @@ -73,7 +73,7 @@ def GetConfigurationForDevice(device_id): has_root = False finally: logging.getLogger().disabled = False - cmd_output = device.old_interface.RunShellCommand(cmd) + cmd_output = device.RunShellCommand(cmd) configuration = { 'id': device_id, diff --git a/build/android/host_heartbeat.py b/build/android/host_heartbeat.py index 4231069..429fca9 100755 --- a/build/android/host_heartbeat.py +++ b/build/android/host_heartbeat.py @@ -22,7 +22,7 @@ def main(): try: devices = android_commands.GetAttachedDevices() for device_serial in devices: - device_utils.DeviceUtils(device_serial).old_interface.RunShellCommand( + device_utils.DeviceUtils(device_serial).RunShellCommand( 'touch /sdcard/host_heartbeat') except: # Keep the heatbeat running bypassing all errors. diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py index ea6d807..859fcbbe 100755 --- a/build/android/provision_devices.py +++ b/build/android/provision_devices.py @@ -84,8 +84,9 @@ def _ConfigureLocalProperties(device): constants.DEVICE_LOCAL_PROPERTIES_PATH, '\n'.join(local_props)) # Android will not respect the local props file if it is world writable. - device.old_interface.RunShellCommandWithSU( - 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH) + device.RunShellCommand( + 'chmod 644 %s' % constants.DEVICE_LOCAL_PROPERTIES_PATH, + root=True) # LOCAL_PROPERTIES_PATH = '/data/local.prop' @@ -105,23 +106,23 @@ def WipeDeviceData(device): device_authorized = device.old_interface.FileExistsOnDevice( constants.ADB_KEYS_FILE) if device_authorized: - adb_keys = device.old_interface.RunShellCommandWithSU( - 'cat %s' % constants.ADB_KEYS_FILE) - device.old_interface.RunShellCommandWithSU('wipe data') + adb_keys = device.RunShellCommand('cat %s' % constants.ADB_KEYS_FILE, + root=True) + device.RunShellCommand('wipe data', root=True) if device_authorized: path_list = constants.ADB_KEYS_FILE.split('/') dir_path = '/'.join(path_list[:len(path_list)-1]) - device.old_interface.RunShellCommandWithSU('mkdir -p %s' % dir_path) - device.old_interface.RunShellCommand('echo %s > %s' % - (adb_keys[0], constants.ADB_KEYS_FILE)) + device.RunShellCommand('mkdir -p %s' % dir_path, root=True) + device.RunShellCommand('echo %s > %s' % + (adb_keys[0], constants.ADB_KEYS_FILE)) for adb_key in adb_keys[1:]: - device.old_interface.RunShellCommand( + device.RunShellCommand( 'echo %s >> %s' % (adb_key, constants.ADB_KEYS_FILE)) def ProvisionDevices(options): # TODO(jbudorick): Parallelize provisioning of all attached devices after - # swithcing from AndroidCommands. + # switching from AndroidCommands. if options.device is not None: devices = [options.device] else: @@ -134,7 +135,7 @@ def ProvisionDevices(options): device.old_interface.EnableAdbRoot() WipeDeviceData(device) try: - device_utils.DeviceUtils.parallel(devices).old_interface.Reboot(True) + device_utils.DeviceUtils.parallel(devices).Reboot(True) except errors.DeviceUnresponsiveError: pass for device_serial in devices: @@ -173,7 +174,7 @@ def ProvisionDevices(options): battery_info.get('level', 0)) time.sleep(60) battery_info = device.old_interface.GetBatteryInfo() - device.old_interface.RunShellCommandWithSU('date -u %f' % time.time()) + device.RunShellCommand('date -u %f' % time.time(), root=True) try: device_utils.DeviceUtils.parallel(devices).Reboot(True) except errors.DeviceUnresponsiveError: diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py index f7264b0..3212143 100644 --- a/build/android/pylib/android_commands.py +++ b/build/android/pylib/android_commands.py @@ -656,12 +656,10 @@ class AndroidCommands(object): preferred_apis = { 'getprop': 'system_properties[<PROPERTY>]', 'setprop': 'system_properties[<PROPERTY>]', - 'su': 'RunShellCommandWithSU()', } # A dict of commands to methods that may call them. whitelisted_callers = { - 'su': 'RunShellCommandWithSU', 'getprop': 'ProvisionDevices', } diff --git a/build/android/pylib/content_settings.py b/build/android/pylib/content_settings.py index 11bc5fd..54cedfe 100644 --- a/build/android/pylib/content_settings.py +++ b/build/android/pylib/content_settings.py @@ -40,8 +40,8 @@ class ContentSettings(dict): def iteritems(self): # Example row: # 'Row: 0 _id=13, name=logging_id2, value=-1fccbaa546705b05' - for row in self._device.old_interface.RunShellCommandWithSU( - 'content query --uri content://%s' % self._table): + for row in self._device.RunShellCommand( + 'content query --uri content://%s' % self._table, root=True): fields = row.split(', ') key = None value = None @@ -55,28 +55,31 @@ class ContentSettings(dict): yield key, value def __getitem__(self, key): - return self._device.old_interface.RunShellCommandWithSU( + return self._device.RunShellCommand( 'content query --uri content://%s --where "name=\'%s\'" ' - '--projection value' % (self._table, key)).strip() + '--projection value' % (self._table, key), root=True).strip() def __setitem__(self, key, value): if key in self: - self._device.old_interface.RunShellCommandWithSU( + self._device.RunShellCommand( 'content update --uri content://%s ' '--bind value:%s:%s --where "name=\'%s\'"' % ( self._table, - self._GetTypeBinding(value), value, key)) + self._GetTypeBinding(value), value, key), + root=True) else: - self._device.old_interface.RunShellCommandWithSU( + self._device.RunShellCommand( 'content insert --uri content://%s ' '--bind name:%s:%s --bind value:%s:%s' % ( self._table, self._GetTypeBinding(key), key, - self._GetTypeBinding(value), value)) + self._GetTypeBinding(value), value), + root=True) def __delitem__(self, key): - self._device.old_interface.RunShellCommandWithSU( + self._device.RunShellCommand( 'content delete --uri content://%s ' '--bind name:%s:%s' % ( self._table, - self._GetTypeBinding(key), key)) + self._GetTypeBinding(key), key), + root=True) diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py index 9701923..0fee10a 100644 --- a/build/android/pylib/device/device_utils.py +++ b/build/android/pylib/device/device_utils.py @@ -99,6 +99,17 @@ class DeviceUtils(object): Returns: True if adbd has root privileges, False otherwise. """ + return self._HasRootImpl() + + def _HasRootImpl(self): + """ Implementation of HasRoot. + + This is split from HasRoot to allow other DeviceUtils methods to call + HasRoot without spawning a new timeout thread. + + Returns: + Same as for |HasRoot|. + """ return self.old_interface.IsRootEnabled() @decorators.WithTimeoutAndRetriesFromInstance() @@ -171,7 +182,7 @@ class DeviceUtils(object): self.old_interface.WaitForSdCardReady(timeout) if wifi: while not 'Wi-Fi is enabled' in ( - self.old_interface.RunShellCommand('dumpsys wifi')): + self._RunShellCommandImpl('dumpsys wifi')): time.sleep(0.1) @decorators.WithTimeoutAndRetriesDefaults( @@ -232,6 +243,61 @@ class DeviceUtils(object): raise device_errors.CommandFailedError( ['adb', 'install', apk_path], str(e)) + @decorators.WithTimeoutAndRetriesFromInstance() + def RunShellCommand(self, cmd, check_return=False, root=False, timeout=None, + retries=None): + """Run an ADB shell command. + + TODO(jbudorick) Switch the default value of check_return to True after + AndroidCommands is gone. + + Args: + cmd: A list containing the command to run on the device and any arguments. + check_return: A boolean indicating whether or not the return code should + be checked. + timeout: Same as for |IsOnline|. + retries: Same as for |IsOnline|. + Raises: + CommandFailedError if check_return is True and the return code is nozero. + Returns: + The output of the command. + """ + return self._RunShellCommandImpl(cmd, check_return=check_return, root=root, + timeout=timeout) + + def _RunShellCommandImpl(self, cmd, check_return=False, root=False, + timeout=None): + """Implementation of RunShellCommand. + + This is split from RunShellCommand to allow other DeviceUtils methods to + call RunShellCommand without spawning a new timeout thread. + + TODO(jbudorick) Remove the timeout parameter once this is no longer + implemented via AndroidCommands. + + Args: + cmd: Same as for |RunShellCommand|. + check_return: Same as for |RunShellCommand|. + timeout: Same as for |IsOnline|. + Raises: + Same as for |RunShellCommand|. + Returns: + Same as for |RunShellCommand|. + """ + if isinstance(cmd, list): + cmd = ' '.join(cmd) + if root and not self.HasRoot(): + cmd = 'su -c %s' % cmd + if check_return: + code, output = self.old_interface.GetShellCommandStatusAndOutput( + cmd, timeout_time=timeout) + if int(code) != 0: + raise device_errors.CommandFailedError( + cmd, 'Nonzero exit code (%d)' % code) + else: + output = self.old_interface.RunShellCommand(cmd, timeout_time=timeout) + return output + def __str__(self): """Returns the device serial.""" return self.old_interface.GetDevice() diff --git a/build/android/pylib/flag_changer.py b/build/android/pylib/flag_changer.py index c1e8cb8..9ccdc1e 100644 --- a/build/android/pylib/flag_changer.py +++ b/build/android/pylib/flag_changer.py @@ -114,11 +114,7 @@ class FlagChanger(object): assert len(file_contents) == 1 and file_contents[0] == cmd_line, ( 'Failed to set the command line file at %s' % self._cmdline_file) else: - if use_root: - self._device.old_interface.RunShellCommandWithSU( - 'rm ' + self._cmdline_file) - else: - self._device.old_interface.RunShellCommand('rm ' + self._cmdline_file) + self._device.RunShellCommand('rm ' + self._cmdline_file, root=use_root) assert ( not self._device.old_interface.FileExistsOnDevice( self._cmdline_file)), ( diff --git a/build/android/pylib/gtest/test_package_apk.py b/build/android/pylib/gtest/test_package_apk.py index 83b6b00..f431526 100644 --- a/build/android/pylib/gtest/test_package_apk.py +++ b/build/android/pylib/gtest/test_package_apk.py @@ -55,7 +55,7 @@ class TestPackageApk(TestPackage): return '/data/data/' + self._package_info.package + '/files/test.fifo' def _ClearFifo(self, device): - device.old_interface.RunShellCommand('rm -f ' + self._GetFifo()) + device.RunShellCommand('rm -f ' + self._GetFifo()) def _WatchFifo(self, device, timeout, logfile=None): for i in range(10): @@ -86,9 +86,9 @@ class TestPackageApk(TestPackage): # files over time. if self.suite_name == 'content_browsertests': try: - device.old_interface.RunShellCommand( + device.RunShellCommand( 'rm -r %s/content_shell' % device.GetExternalStoragePath(), - timeout_time=60 * 2) + timeout=60 * 2) except device_errors.CommandFailedError: # TODO(jbudorick) Handle this exception appropriately once the # conversions are done. diff --git a/build/android/pylib/gtest/test_package_exe.py b/build/android/pylib/gtest/test_package_exe.py index 18146ad..252c4a4 100644 --- a/build/android/pylib/gtest/test_package_exe.py +++ b/build/android/pylib/gtest/test_package_exe.py @@ -106,7 +106,7 @@ class TestPackageExecutable(TestPackage): #override def GetAllTests(self, device): - all_tests = device.old_interface.RunShellCommand( + all_tests = device.RunShellCommand( '%s %s/%s --gtest_list_tests' % (self.tool.GetTestWrapper(), constants.TEST_EXECUTABLE_DIR, diff --git a/build/android/pylib/instrumentation/test_runner.py b/build/android/pylib/instrumentation/test_runner.py index 12ae702..050985f 100644 --- a/build/android/pylib/instrumentation/test_runner.py +++ b/build/android/pylib/instrumentation/test_runner.py @@ -154,8 +154,8 @@ class TestRunner(base_test_runner.BaseTestRunner): if self.device.old_interface.SetJavaAssertsEnabled(True): # TODO(jbudorick) How to best do shell restart after the # android_commands refactor? - self.device.old_interface.RunShellCommand('stop') - self.device.old_interface.RunShellCommand('start') + self.device.RunShellCommand('stop') + self.device.RunShellCommand('start') # We give different default value to launch HTTP server based on shard index # because it may have race condition when multiple processes are trying to @@ -237,7 +237,7 @@ class TestRunner(base_test_runner.BaseTestRunner): if self.coverage_dir: self.device.old_interface.Adb().Pull( self.coverage_device_file, self.coverage_host_file) - self.device.old_interface.RunShellCommand( + self.device.RunShellCommand( 'rm -f %s' % self.coverage_device_file) def TearDownPerfMonitoring(self, test): diff --git a/build/android/pylib/linker/test_case.py b/build/android/pylib/linker/test_case.py index 0530f53..e8b2ffe 100644 --- a/build/android/pylib/linker/test_case.py +++ b/build/android/pylib/linker/test_case.py @@ -112,7 +112,7 @@ def _WriteCommandLineFile(device, command_line, command_line_file): """Create a command-line file on the device. This does not use FlagChanger because its implementation assumes the device has 'su', and thus does not work at all with production devices.""" - device.old_interface.RunShellCommand( + device.RunShellCommand( 'echo "%s" > %s' % (command_line, command_line_file)) diff --git a/build/android/pylib/monkey/test_runner.py b/build/android/pylib/monkey/test_runner.py index 31d8851..5f0cc5d 100644 --- a/build/android/pylib/monkey/test_runner.py +++ b/build/android/pylib/monkey/test_runner.py @@ -40,8 +40,7 @@ class TestRunner(base_test_runner.BaseTestRunner): '--kill-process-after-error', self._options.extra_args, '%d' % self._options.event_count] - return self.device.old_interface.RunShellCommand( - ' '.join(cmd), timeout_time=timeout_ms) + return self.device.RunShellCommand(' '.join(cmd), timeout=timeout_ms) def RunTest(self, test_name): """Run a Monkey test on the device. diff --git a/build/android/pylib/perf/cache_control.py b/build/android/pylib/perf/cache_control.py index adc3219..09107db 100644 --- a/build/android/pylib/perf/cache_control.py +++ b/build/android/pylib/perf/cache_control.py @@ -16,7 +16,7 @@ class CacheControl(object): def DropRamCaches(self): """Drops the filesystem ram caches for performance testing.""" - self._device.old_interface.RunShellCommandWithSU('sync') + self._device.RunShellCommand('sync', root=True) self._device.old_interface.SetProtectedFileContents( CacheControl._DROP_CACHES, '3') diff --git a/build/android/pylib/perf/perf_control.py b/build/android/pylib/perf/perf_control.py index cde12ec..1c88945 100644 --- a/build/android/pylib/perf/perf_control.py +++ b/build/android/pylib/perf/perf_control.py @@ -73,12 +73,11 @@ class PerfControl(object): """ def ForceCpuOnline(online_path): script = 'chmod 644 {0}; echo 1 > {0}; chmod 444 {0}'.format(online_path) - self._device.old_interface.RunShellCommandWithSU(script) + self._device.RunShellCommand(script, root=True) return self._device.old_interface.GetFileContents(online_path)[0] == '1' def ResetCpu(online_path): - self._device.old_interface.RunShellCommandWithSU( - 'chmod 644 %s' % online_path) + self._device.RunShellCommand('chmod 644 %s' % online_path, root=True) def WaitFor(condition): for _ in range(100): @@ -87,7 +86,7 @@ class PerfControl(object): time.sleep(0.1) raise RuntimeError('Timed out') - cpu_online_files = self._device.old_interface.RunShellCommand( + cpu_online_files = self._device.RunShellCommand( 'ls -d /sys/devices/system/cpu/cpu[0-9]*/online') for online_path in cpu_online_files: if force_online: diff --git a/build/android/pylib/perf/perf_control_unittest.py b/build/android/pylib/perf/perf_control_unittest.py index bd30a4e..a83b482 100644 --- a/build/android/pylib/perf/perf_control_unittest.py +++ b/build/android/pylib/perf/perf_control_unittest.py @@ -25,20 +25,20 @@ class TestPerfControl(unittest.TestCase): def testForceAllCpusOnline(self): perf = perf_control.PerfControl(self._device) - cpu_online_files = self._device.old_interface.RunShellCommand( + cpu_online_files = self._device.RunShellCommand( 'ls -d /sys/devices/system/cpu/cpu[0-9]*/online') try: perf.ForceAllCpusOnline(True) for path in cpu_online_files: self.assertEquals('1', self._device.old_interface.GetFileContents(path)[0]) - mode = self._device.old_interface.RunShellCommand('ls -l %s' % path)[0] + mode = self._device.RunShellCommand('ls -l %s' % path)[0] self.assertEquals('-r--r--r--', mode[:10]) finally: perf.ForceAllCpusOnline(False) for path in cpu_online_files: - mode = self._device.old_interface.RunShellCommand('ls -l %s' % path)[0] + mode = self._device.RunShellCommand('ls -l %s' % path)[0] self.assertEquals('-rw-r--r--', mode[:10]) diff --git a/build/android/pylib/perf/surface_stats_collector.py b/build/android/pylib/perf/surface_stats_collector.py index 223e18c..a34d87d1 100644 --- a/build/android/pylib/perf/surface_stats_collector.py +++ b/build/android/pylib/perf/surface_stats_collector.py @@ -215,7 +215,7 @@ class SurfaceStatsCollector(object): """ # The command returns nothing if it is supported, otherwise returns many # lines of result just like 'dumpsys SurfaceFlinger'. - results = self._device.old_interface.RunShellCommand( + results = self._device.RunShellCommand( 'dumpsys SurfaceFlinger --latency-clear SurfaceView') return not len(results) @@ -258,9 +258,8 @@ class SurfaceStatsCollector(object): # We use the special "SurfaceView" window name because the statistics for # the activity's main window are not updated when the main web content is # composited into a SurfaceView. - results = self._device.old_interface.RunShellCommand( - 'dumpsys SurfaceFlinger --latency SurfaceView', - log_result=logging.getLogger().isEnabledFor(logging.DEBUG)) + results = self._device.RunShellCommand( + 'dumpsys SurfaceFlinger --latency SurfaceView') if not len(results): return (None, None) @@ -296,8 +295,7 @@ class SurfaceStatsCollector(object): Returns: Dict of {page_flip_count (or 0 if there was an error), timestamp}. """ - results = self._device.old_interface.RunShellCommand( - 'service call SurfaceFlinger 1013') + results = self._device.RunShellCommand('service call SurfaceFlinger 1013') assert len(results) == 1 match = re.search('^Result: Parcel\((\w+)', results[0]) cur_surface = 0 diff --git a/build/android/pylib/perf/thermal_throttle.py b/build/android/pylib/perf/thermal_throttle.py index 60156de..87ae966 100644 --- a/build/android/pylib/perf/thermal_throttle.py +++ b/build/android/pylib/perf/thermal_throttle.py @@ -102,7 +102,7 @@ class ThermalThrottle(object): return False has_been_throttled = False serial_number = self._device.old_interface.GetDevice() - log = self._device.old_interface.RunShellCommand('dmesg -c') + log = self._device.RunShellCommand('dmesg -c') degree_symbol = unichr(0x00B0) for line in log: if self._detector.BecameThrottled(line): @@ -128,8 +128,7 @@ class ThermalThrottle(object): serial_number, temperature, degree_symbol) # Print temperature of battery, to give a system temperature - dumpsys_log = self._device.old_interface.RunShellCommand( - 'dumpsys battery') + dumpsys_log = self._device.RunShellCommand('dumpsys battery') for line in dumpsys_log: if 'temperature' in line: btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 diff --git a/build/android/pylib/ports.py b/build/android/pylib/ports.py index 88b7cb2..34efb52 100644 --- a/build/android/pylib/ports.py +++ b/build/android/pylib/ports.py @@ -114,8 +114,7 @@ def IsDevicePortUsed(device, device_port, state=''): True if the port on device is already used, otherwise returns False. """ base_url = '127.0.0.1:%d' % device_port - netstat_results = device.old_interface.RunShellCommand( - 'netstat', log_result=False) + netstat_results = device.RunShellCommand('netstat') for single_connect in netstat_results: # Column 3 is the local address which we want to check with. connect_results = single_connect.split() diff --git a/build/android/pylib/screenshot.py b/build/android/pylib/screenshot.py index 5cf3c26..a09bc3d 100644 --- a/build/android/pylib/screenshot.py +++ b/build/android/pylib/screenshot.py @@ -76,7 +76,7 @@ class VideoRecorder(object): self._is_started = False if not self._recorder or not self._recorder_pids: return - self._device.old_interface.RunShellCommand( + self._device.RunShellCommand( 'kill -SIGINT ' + ' '.join(self._recorder_pids)) self._recorder.wait() @@ -88,5 +88,5 @@ class VideoRecorder(object): """ self._device.old_interface.PullFileFromDevice( self._device_file, self._host_file) - self._device.old_interface.RunShellCommand('rm -f "%s"' % self._device_file) + self._device.RunShellCommand('rm -f "%s"' % self._device_file) return self._host_file diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py index 91aa23e..81b9c98 100644 --- a/build/android/pylib/utils/emulator.py +++ b/build/android/pylib/utils/emulator.py @@ -394,6 +394,7 @@ class Emulator(object): """ seconds_waited = 0 number_of_waits = 2 # Make sure we can wfd twice + # TODO(jbudorick) Un-handroll this in the implementation switch. adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device') while seconds_waited < self._LAUNCH_TIMEOUT: try: diff --git a/build/android/pylib/valgrind_tools.py b/build/android/pylib/valgrind_tools.py index 0c94557..8f845fb 100644 --- a/build/android/pylib/valgrind_tools.py +++ b/build/android/pylib/valgrind_tools.py @@ -37,7 +37,7 @@ def SetChromeTimeoutScale(device, scale): path = '/data/local/tmp/chrome_timeout_scale' if not scale or scale == 1.0: # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 - device.old_interface.RunShellCommand('rm %s' % path) + device.RunShellCommand('rm %s' % path) else: device.old_interface.SetProtectedFileContents(path, '%f' % scale) @@ -166,9 +166,9 @@ class ValgrindTool(BaseTool): def CopyFiles(self): """Copies Valgrind tools to the device.""" - self._device.old_interface.RunShellCommand( + self._device.RunShellCommand( 'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) - self._device.old_interface.RunShellCommand( + self._device.RunShellCommand( 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR, ValgrindTool.VGLOGS_DIR)) files = self.GetFilesForTool() @@ -179,17 +179,17 @@ class ValgrindTool(BaseTool): def SetupEnvironment(self): """Sets up device environment.""" - self._device.old_interface.RunShellCommand('chmod 777 /data/local/tmp') - self._device.old_interface.RunShellCommand('setenforce 0') + self._device.RunShellCommand('chmod 777 /data/local/tmp') + self._device.RunShellCommand('setenforce 0') for prop in self._wrap_properties: - self._device.old_interface.RunShellCommand( + self._device.RunShellCommand( 'setprop %s "logwrapper %s"' % (prop, self.GetTestWrapper())) SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) def CleanUpEnvironment(self): """Cleans up device environment.""" for prop in self._wrap_properties: - self._device.old_interface.RunShellCommand('setprop %s ""' % (prop,)) + self._device.RunShellCommand('setprop %s ""' % (prop,)) SetChromeTimeoutScale(self._device, None) def GetFilesForTool(self): diff --git a/build/android/tombstones.py b/build/android/tombstones.py index cb1d700..76dab15 100755 --- a/build/android/tombstones.py +++ b/build/android/tombstones.py @@ -29,8 +29,7 @@ def _ListTombstones(device): Yields: Tuples of (tombstone filename, date time of file on device). """ - lines = device.old_interface.RunShellCommand( - 'TZ=UTC su -c ls -a -l /data/tombstones') + lines = device.RunShellCommand('TZ=UTC su -c ls -a -l /data/tombstones') for line in lines: if 'tombstone' in line and not 'No such file or directory' in line: details = line.split() @@ -48,7 +47,7 @@ def _GetDeviceDateTime(device): Returns: A datetime instance. """ - device_now_string = device.old_interface.RunShellCommand('TZ=UTC date') + device_now_string = device.RunShellCommand('TZ=UTC date') return datetime.datetime.strptime( device_now_string[0], '%a %b %d %H:%M:%S %Z %Y') @@ -74,8 +73,8 @@ def _EraseTombstone(device, tombstone_file): device: An instance of DeviceUtils. tombstone_file: the tombstone to delete. """ - return device.old_interface.RunShellCommandWithSU( - 'rm /data/tombstones/' + tombstone_file) + return device.RunShellCommand( + 'rm /data/tombstones/' + tombstone_file, root=True) def _ResolveSymbols(tombstone_data, include_stack): |