| 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 41413597b32d4c4fb3a0bbd2e2395b82b2cc50a4..4c5ff87a817f669a4352a51eb2ee0c272e429896 100644
|
| --- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| +++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| @@ -10,7 +10,7 @@ from telemetry.core import exceptions
|
| from telemetry.core import platform
|
| from telemetry.core import util
|
| from telemetry.core import video
|
| -from telemetry.core.platform import proc_supporting_platform_backend
|
| +from telemetry.core.platform import linux_based_platform_backend
|
| from telemetry.core.platform.power_monitor import android_ds2784_power_monitor
|
| from telemetry.core.platform.power_monitor import android_dumpsys_power_monitor
|
| from telemetry.core.platform.power_monitor import android_temperature_monitor
|
| @@ -39,7 +39,7 @@ _HOST_APPLICATIONS = [
|
|
|
|
|
| class AndroidPlatformBackend(
|
| - proc_supporting_platform_backend.ProcSupportingPlatformBackend):
|
| + linux_based_platform_backend.LinuxBasedPlatformBackend):
|
| def __init__(self, device, no_performance_mode):
|
| super(AndroidPlatformBackend, self).__init__()
|
| self._device = device
|
| @@ -51,9 +51,9 @@ class AndroidPlatformBackend(
|
| self._can_access_protected_file_contents = \
|
| self._device.old_interface.CanAccessProtectedFileContents()
|
| power_controller = power_monitor_controller.PowerMonitorController([
|
| - monsoon_power_monitor.MonsoonPowerMonitor(device),
|
| - android_ds2784_power_monitor.DS2784PowerMonitor(device),
|
| - android_dumpsys_power_monitor.DumpsysPowerMonitor(device),
|
| + monsoon_power_monitor.MonsoonPowerMonitor(device, self),
|
| + android_ds2784_power_monitor.DS2784PowerMonitor(device, self),
|
| + android_dumpsys_power_monitor.DumpsysPowerMonitor(device, self),
|
| ])
|
| self._power_monitor = android_temperature_monitor.AndroidTemperatureMonitor(
|
| power_controller, device)
|
| @@ -150,7 +150,7 @@ class AndroidPlatformBackend(
|
|
|
| def GetChildPids(self, pid):
|
| child_pids = []
|
| - ps = self._GetPsOutput(['pid', 'name'])
|
| + ps = self.GetPsOutput(['pid', 'name'])
|
| for curr_pid, curr_name in ps:
|
| if int(curr_pid) == pid:
|
| name = curr_name
|
| @@ -162,7 +162,7 @@ class AndroidPlatformBackend(
|
|
|
| @decorators.Cache
|
| def GetCommandLine(self, pid):
|
| - ps = self._GetPsOutput(['pid', 'name'], pid)
|
| + ps = self.GetPsOutput(['pid', 'name'], pid)
|
| if not ps:
|
| raise exceptions.ProcessGoneException()
|
| return ps[0][1]
|
| @@ -255,13 +255,13 @@ class AndroidPlatformBackend(
|
| def StopMonitoringPower(self):
|
| return self._power_monitor.StopMonitoringPower()
|
|
|
| - def _GetFileContents(self, fname):
|
| + def GetFileContents(self, fname):
|
| if not self._can_access_protected_file_contents:
|
| logging.warning('%s cannot be retrieved on non-rooted device.' % fname)
|
| return ''
|
| return '\n'.join(self._device.ReadFile(fname, as_root=True))
|
|
|
| - def _GetPsOutput(self, columns, pid=None):
|
| + def GetPsOutput(self, columns, pid=None):
|
| assert columns == ['pid', 'name'] or columns == ['pid'], \
|
| 'Only know how to return pid and name. Requested: ' + columns
|
| command = 'ps'
|
| @@ -278,3 +278,29 @@ class AndroidPlatformBackend(
|
| else:
|
| output.append([curr_pid])
|
| return output
|
| +
|
| + def RunCommand(self, command):
|
| + return '\n'.join(self._device.RunShellCommand(command))
|
| +
|
| + @staticmethod
|
| + def ParseCStateSample(sample):
|
| + sample_stats = {}
|
| + for cpu in sample:
|
| + values = sample[cpu].splitlines()
|
| + # Each state has three values after excluding the time value.
|
| + num_states = (len(values) - 1) / 3
|
| + names = values[:num_states]
|
| + times = values[num_states:2 * num_states]
|
| + cstates = {'C0': int(values[-1]) * 10 ** 6}
|
| + for i, state in enumerate(names):
|
| + if state == 'C0':
|
| + # The Exynos cpuidle driver for the Nexus 10 uses the name 'C0' for
|
| + # its WFI state.
|
| + # TODO(tmandel): We should verify that no other Android device
|
| + # actually reports time in C0 causing this to report active time as
|
| + # idle time.
|
| + state = 'WFI'
|
| + cstates[state] = int(times[i])
|
| + cstates['C0'] -= int(times[i])
|
| + sample_stats[cpu] = cstates
|
| + return sample_stats
|
|
|