Chromium Code Reviews| Index: tools/telemetry/telemetry/core/platform/android_platform_backend.py |
| diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py |
| index 0fcd4c64abf47cccdbf7c0066a5ec368bc8a5300..9968cefdfc801ccf58beaf4f4f571617f47dac9c 100644 |
| --- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py |
| +++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py |
| @@ -37,13 +37,13 @@ import platformsettings # pylint: disable=import-error |
| # Get build/android scripts into our path. |
| util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') |
| +from pylib import constants # pylint: disable=F0401 |
| +from pylib import screenshot # pylint: disable=F0401 |
| from pylib.device import battery_utils # pylint: disable=F0401 |
| from pylib.perf import cache_control # pylint: disable=F0401 |
| from pylib.perf import perf_control # pylint: disable=F0401 |
| from pylib.perf import thermal_throttle # pylint: disable=F0401 |
| from pylib.utils import device_temp_file # pylint: disable=F0401 |
| -from pylib import constants # pylint: disable=F0401 |
| -from pylib import screenshot # pylint: disable=F0401 |
| try: |
| from pylib.perf import surface_stats_collector # pylint: disable=import-error |
| @@ -51,6 +51,11 @@ except Exception: |
| surface_stats_collector = None |
| +_EFFICIENT_DEVICE_COPY_SCRIPT_FILE = os.path.join( |
| + constants.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', |
| + 'efficient_android_directory_copy.sh') |
| + |
| + |
| class AndroidPlatformBackend( |
| linux_based_platform_backend.LinuxBasedPlatformBackend): |
| def __init__(self, device, finder_options): |
| @@ -76,8 +81,9 @@ class AndroidPlatformBackend( |
| self._perf_tests_setup = perf_control.PerfControl(self._device) |
| self._thermal_throttle = thermal_throttle.ThermalThrottle(self._device) |
| self._raw_display_frame_rate_measurements = [] |
| - self._can_access_protected_file_contents = \ |
| - self._device.old_interface.CanAccessProtectedFileContents() |
| + self._can_access_protected_file_contents = ( |
| + self._device.HasRoot() or self._device.NeedsSU()) |
| + self._efficient_device_copy_script = None |
| power_controller = power_monitor_controller.PowerMonitorController([ |
| monsoon_power_monitor.MonsoonPowerMonitor(self._device, self), |
| android_ds2784_power_monitor.DS2784PowerMonitor(self._device, self), |
| @@ -99,6 +105,10 @@ class AndroidPlatformBackend( |
| _FixPossibleAdbInstability() |
| + def __del__(self): |
|
Sami
2015/05/12 18:37:10
This seems a little risky since the finalizer can
jbudorick
2015/05/13 03:21:22
I'm not sure what you mean by this. Can you elabor
Sami
2015/05/13 12:58:51
I meant that it's not at all deterministic if or w
jbudorick
2015/05/13 21:49:29
Sometimes I miss c++.
|
| + if self._efficient_device_copy_script: |
| + self._efficient_device_copy_script.close() |
| + |
| @classmethod |
| def SupportsDevice(cls, device): |
| return isinstance(device, android_device.AndroidDevice) |
| @@ -201,11 +211,11 @@ class AndroidPlatformBackend( |
| if not android_prebuilt_profiler_helper.InstallOnDevice( |
| self._device, 'purge_ashmem'): |
| raise Exception('Error installing purge_ashmem.') |
| - (status, output) = self._device.old_interface.GetAndroidToolStatusAndOutput( |
| + output = self._device.RunShellCommand( |
| android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem'), |
| - log_result=True) |
| - if status != 0: |
| - raise Exception('Error while purging ashmem: ' + '\n'.join(output)) |
| + check_return=True) |
| + for l in output: |
| + logging.info(l) |
| def GetMemoryStats(self, pid): |
| memory_usage = self._device.GetMemoryUsageForPid(pid) |
| @@ -530,7 +540,7 @@ class AndroidPlatformBackend( |
| self._device.PushChangedFiles([(new_profile_dir, saved_profile_location)]) |
| profile_dir = self._GetProfileDir(package) |
| - self._device.old_interface.EfficientDeviceDirectoryCopy( |
| + self._EfficientDeviceDirectoryCopy( |
| saved_profile_location, profile_dir) |
| dumpsys = self._device.RunShellCommand('dumpsys package %s' % package) |
| id_line = next(line for line in dumpsys if 'userId=' in line) |
| @@ -544,6 +554,19 @@ class AndroidPlatformBackend( |
| self._device.RunShellCommand( |
| 'chown %s.%s %s' % (uid, uid, extended_path)) |
| + def _EfficientDeviceDirectoryCopy(self, source, dest): |
| + if not self._efficient_device_copy_script: |
| + efficient_device_copy_script = device_temp_file.DeviceTempFile( |
| + self._device.adb, suffix='.sh') |
| + self._device.adb.Push( |
| + _EFFICIENT_DEVICE_COPY_SCRIPT_FILE, |
| + efficient_device_copy_script.name) |
| + self._efficient_device_copy_script = efficient_device_copy_script |
| + |
| + self._device.RunShellCommand( |
| + ['sh', self._efficient_device_copy_script.name, source, dest], |
| + check_return=True) |
| + |
| def RemoveProfile(self, package, ignore_list): |
| """Delete application profile on device. |
| @@ -574,17 +597,14 @@ class AndroidPlatformBackend( |
| # pulled down is really needed e.g. .pak files. |
| if not os.path.exists(output_profile_path): |
| os.makedirs(output_profile_path) |
| - files = self._device.RunShellCommand('ls "%s"' % profile_dir) |
| + files = self._device.RunShellCommand( |
| + ['ls', profile_dir], check_return=True) |
| for f in files: |
| # Don't pull lib, since it is created by the installer. |
| if f != 'lib': |
| source = '%s%s' % (profile_dir, f) |
| dest = os.path.join(output_profile_path, f) |
| - # self._adb.Pull(source, dest) doesn't work because its timeout |
| - # is fixed in android's adb_interface at 60 seconds, which may |
| - # be too short to pull the cache. |
| - cmd = 'pull %s %s' % (source, dest) |
| - self._device.old_interface.Adb().SendCommand(cmd, timeout_time=240) |
| + self._device.PullFile(source, dest, timeout=240) |
| def _GetProfileDir(self, package): |
| """Returns the on-device location where the application profile is stored |