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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 23477053: Telemetry: fix permission check when setting Android command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove wrapper method from adb_commands Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1466
1467 status = self._adb.SendShellCommand( 1467 status = self._adb.SendShellCommand(
1468 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) 1468 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name))
1469 return int(status) == 0 1469 return int(status) == 0
1470 except ValueError: 1470 except ValueError:
1471 if IsDeviceAttached(self._device): 1471 if IsDeviceAttached(self._device):
1472 raise errors.DeviceUnresponsiveError('Device may be offline.') 1472 raise errors.DeviceUnresponsiveError('Device may be offline.')
1473 1473
1474 return False 1474 return False
1475 1475
1476 def IsFileWritableOnDevice(self, file_name):
1477 """Checks whether the given file (or directory) is writable on the device.
1478
1479 Args:
1480 file_name: Full path of file/directory to check.
1481
1482 Returns:
1483 True if writable, False otherwise.
1484 """
1485 assert '"' not in file_name, 'file_name cannot contain double quotes'
1486 try:
1487 status = self._adb.SendShellCommand(
1488 '\'test -w "%s"; echo $?\'' % (file_name))
1489 if 'test: not found' not in status:
1490 return int(status) == 0
1491 raise errors.AbortError('"test" binary not found. OS too old.')
1492
1493 except ValueError:
1494 if IsDeviceAttached(self._device):
1495 raise errors.DeviceUnresponsiveError('Device may be offline.')
1496
1497 return False
1498
1476 def TakeScreenshot(self, host_file): 1499 def TakeScreenshot(self, host_file):
1477 """Saves a screenshot image to |host_file| on the host. 1500 """Saves a screenshot image to |host_file| on the host.
1478 1501
1479 Args: 1502 Args:
1480 host_file: Absolute path to the image file to store on the host. 1503 host_file: Absolute path to the image file to store on the host.
1481 """ 1504 """
1482 host_dir = os.path.dirname(host_file) 1505 host_dir = os.path.dirname(host_file)
1483 if not os.path.exists(host_dir): 1506 if not os.path.exists(host_dir):
1484 os.makedirs(host_dir) 1507 os.makedirs(host_dir)
1485 device_file = '%s/screenshot.png' % self.GetExternalStorage() 1508 device_file = '%s/screenshot.png' % self.GetExternalStorage()
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 """ 1575 """
1553 def __init__(self, output): 1576 def __init__(self, output):
1554 self._output = output 1577 self._output = output
1555 1578
1556 def write(self, data): 1579 def write(self, data):
1557 data = data.replace('\r\r\n', '\n') 1580 data = data.replace('\r\r\n', '\n')
1558 self._output.write(data) 1581 self._output.write(data)
1559 1582
1560 def flush(self): 1583 def flush(self):
1561 self._output.flush() 1584 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698