import subprocess
import tempfile
+from telemetry import decorators
from telemetry.core import bitmap
from telemetry.core import exceptions
from telemetry.core import platform
from telemetry.core import util
from telemetry.core.platform import proc_supporting_platform_backend
+from telemetry.core.platform.power_monitor import android_ds2784_power_monitor
+from telemetry.core.platform.power_monitor import monsoon_power_monitor
+from telemetry.core.platform.power_monitor import power_monitor_controller
from telemetry.core.platform.profiler import android_prebuilt_profiler_helper
# Get build/android scripts into our path.
self._host_platform_backend = platform.CreatePlatformBackendForCurrentOS()
self._can_access_protected_file_contents = \
self._adb.CanAccessProtectedFileContents()
+ self._powermonitor = power_monitor_controller.PowerMonitorController([
+ monsoon_power_monitor.MonsoonPowerMonitor(),
+ android_ds2784_power_monitor.DS2784PowerMonitor(adb)
+ ])
self._video_recorder = None
self._video_output = None
if self._no_performance_mode:
return int(line.split()[2]) * 1024
return 0
+ @decorators.Cache
+ def GetSystemTotalPhysicalMemory(self):
+ for line in self._adb.RunShellCommand('dumpsys meminfo', log_result=False):
+ if line.startswith('Total RAM: '):
+ return int(line.split()[2]) * 1024
+ return 0
+
def GetCpuStats(self, pid):
if not self._can_access_protected_file_contents:
logging.warning('CPU stats cannot be retrieved on non-rooted device.')
def GetOSName(self):
return 'android'
+ @decorators.Cache
def GetOSVersionName(self):
return self._adb.GetBuildId()[0]
def FlushSystemCacheForDirectory(self, directory, ignoring=None):
raise NotImplementedError()
- def LaunchApplication(self, application, parameters=None):
+ def LaunchApplication(
+ self, application, parameters=None, elevate_privilege=False):
if application in _HOST_APPLICATIONS:
- self._host_platform_backend.LaunchApplication(application, parameters)
+ self._host_platform_backend.LaunchApplication(
+ application, parameters, elevate_privilege=elevate_privilege)
return
+ if elevate_privilege:
+ raise NotImplementedError("elevate_privilege isn't supported on android.")
if not parameters:
parameters = ''
self._adb.RunShellCommand('am start ' + parameters + ' ' + application)
raise NotImplementedError(
'Please teach Telemetry how to install ' + application)
+ @decorators.Cache
def CanCaptureVideo(self):
return self.GetOSVersionName() >= 'K'
for frame in self._FramesFromMp4(self._video_output):
yield frame
+ def CanMonitorPowerAsync(self):
+ return self._powermonitor.CanMonitorPowerAsync()
+
+ def StartMonitoringPowerAsync(self):
+ self._powermonitor.StartMonitoringPowerAsync()
+
+ def StopMonitoringPowerAsync(self):
+ return self._powermonitor.StopMonitoringPowerAsync()
+
def _FramesFromMp4(self, mp4_file):
if not self.CanLaunchApplication('avconv'):
self.InstallApplication('avconv')