1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.core.android_platform</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.core.html"><font color="#ffffff">core</font></a>.android_platform</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/core/android_platform.py">telemetry/core/android_platform.py</a></font></td></tr></table> 13 <p><tt># Copyright 2014 The Chromium Authors. All rights reserved.<br> 14# Use of this source code is governed by a BSD-style license that can be<br> 15# found in the LICENSE file.</tt></p> 16<p> 17<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 18<tr bgcolor="#aa55cc"> 19<td colspan=3 valign=bottom> <br> 20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 21 22<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 23<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="telemetry.core.android_action_runner.html">telemetry.core.android_action_runner</a><br> 24</td><td width="25%" valign=top><a href="telemetry.internal.app.android_app.html">telemetry.internal.app.android_app</a><br> 25</td><td width="25%" valign=top><a href="telemetry.internal.backends.android_app_backend.html">telemetry.internal.backends.android_app_backend</a><br> 26</td><td width="25%" valign=top><a href="telemetry.core.platform.html">telemetry.core.platform</a><br> 27</td></tr></table></td></tr></table><p> 28<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 29<tr bgcolor="#ee77aa"> 30<td colspan=3 valign=bottom> <br> 31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 32 33<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 34<td width="100%"><dl> 35<dt><font face="helvetica, arial"><a href="telemetry.core.platform.html#Platform">telemetry.core.platform.Platform</a>(<a href="__builtin__.html#object">__builtin__.object</a>) 36</font></dt><dd> 37<dl> 38<dt><font face="helvetica, arial"><a href="telemetry.core.android_platform.html#AndroidPlatform">AndroidPlatform</a> 39</font></dt></dl> 40</dd> 41</dl> 42 <p> 43<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 44<tr bgcolor="#ffc8d8"> 45<td colspan=3 valign=bottom> <br> 46<font color="#000000" face="helvetica, arial"><a name="AndroidPlatform">class <strong>AndroidPlatform</strong></a>(<a href="telemetry.core.platform.html#Platform">telemetry.core.platform.Platform</a>)</font></td></tr> 47 48<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> 49<td width="100%"><dl><dt>Method resolution order:</dt> 50<dd><a href="telemetry.core.android_platform.html#AndroidPlatform">AndroidPlatform</a></dd> 51<dd><a href="telemetry.core.platform.html#Platform">telemetry.core.platform.Platform</a></dd> 52<dd><a href="__builtin__.html#object">__builtin__.object</a></dd> 53</dl> 54<hr> 55Methods defined here:<br> 56<dl><dt><a name="AndroidPlatform-LaunchAndroidApplication"><strong>LaunchAndroidApplication</strong></a>(self, start_intent, is_app_ready_predicate<font color="#909090">=None</font>, app_has_webviews<font color="#909090">=True</font>)</dt><dd><tt>Launches an Android application given the intent.<br> 57 <br> 58Args:<br> 59 start_intent: The intent to use to start the app.<br> 60 is_app_ready_predicate: A predicate function to determine<br> 61 whether the app is ready. This is a function that takes an<br> 62 AndroidApp instance and return a boolean. When it is not passed in,<br> 63 the app is ready when the intent to launch it is completed.<br> 64 app_has_webviews: A boolean indicating whether the app is expected to<br> 65 contain any WebViews. If True, the app will be launched with<br> 66 appropriate webview flags, and the GetWebViews method of the returned<br> 67 object may be used to access them.<br> 68 <br> 69Returns:<br> 70 A reference to the android_app launched.</tt></dd></dl> 71 72<dl><dt><a name="AndroidPlatform-__init__"><strong>__init__</strong></a>(self, platform_backend)</dt></dl> 73 74<hr> 75Data descriptors defined here:<br> 76<dl><dt><strong>android_action_runner</strong></dt> 77</dl> 78<hr> 79Methods inherited from <a href="telemetry.core.platform.html#Platform">telemetry.core.platform.Platform</a>:<br> 80<dl><dt><a name="AndroidPlatform-CanCaptureVideo"><strong>CanCaptureVideo</strong></a>(self)</dt><dd><tt>Returns a bool indicating whether the platform supports video capture.</tt></dd></dl> 81 82<dl><dt><a name="AndroidPlatform-CanFlushIndividualFilesFromSystemCache"><strong>CanFlushIndividualFilesFromSystemCache</strong></a>(self)</dt><dd><tt>Returns true if the disk cache can be flushed for specific files.</tt></dd></dl> 83 84<dl><dt><a name="AndroidPlatform-CanLaunchApplication"><strong>CanLaunchApplication</strong></a>(self, application)</dt><dd><tt>Returns whether the platform can launch the given application.</tt></dd></dl> 85 86<dl><dt><a name="AndroidPlatform-CanMeasurePerApplicationPower"><strong>CanMeasurePerApplicationPower</strong></a>(self)</dt><dd><tt>Returns True if the power monitor can measure power for the target<br> 87application in isolation. False if power measurement is for full system<br> 88energy consumption.</tt></dd></dl> 89 90<dl><dt><a name="AndroidPlatform-CanMonitorNetworkData"><strong>CanMonitorNetworkData</strong></a>(self)</dt><dd><tt>Returns true if network data can be retrieved, false otherwise.</tt></dd></dl> 91 92<dl><dt><a name="AndroidPlatform-CanMonitorPower"><strong>CanMonitorPower</strong></a>(self)</dt><dd><tt>Returns True iff power can be monitored asynchronously via<br> 93<a href="#AndroidPlatform-StartMonitoringPower">StartMonitoringPower</a>() and <a href="#AndroidPlatform-StopMonitoringPower">StopMonitoringPower</a>().</tt></dd></dl> 94 95<dl><dt><a name="AndroidPlatform-CanMonitorThermalThrottling"><strong>CanMonitorThermalThrottling</strong></a>(self)</dt><dd><tt>Platforms may be able to detect thermal throttling.<br> 96 <br> 97Some fan-less computers go into a reduced performance mode when their heat<br> 98exceeds a certain threshold. Performance tests in particular should use this<br> 99API to detect if this has happened and interpret results accordingly.</tt></dd></dl> 100 101<dl><dt><a name="AndroidPlatform-CanTakeScreenshot"><strong>CanTakeScreenshot</strong></a>(self)</dt></dl> 102 103<dl><dt><a name="AndroidPlatform-CooperativelyShutdown"><strong>CooperativelyShutdown</strong></a>(self, proc, app_name)</dt><dd><tt>Cooperatively shut down the given process from subprocess.Popen.<br> 104 <br> 105Currently this is only implemented on Windows. See<br> 106crbug.com/424024 for background on why it was added.<br> 107 <br> 108Args:<br> 109 proc: a process object returned from subprocess.Popen.<br> 110 app_name: on Windows, is the prefix of the application's window<br> 111 class name that should be searched for. This helps ensure<br> 112 that only the application's windows are closed.<br> 113 <br> 114Returns True if it is believed the attempt succeeded.</tt></dd></dl> 115 116<dl><dt><a name="AndroidPlatform-FlushDnsCache"><strong>FlushDnsCache</strong></a>(self)</dt><dd><tt>Flushes the OS's DNS cache completely.<br> 117 <br> 118This function may require root or administrator access.</tt></dd></dl> 119 120<dl><dt><a name="AndroidPlatform-FlushEntireSystemCache"><strong>FlushEntireSystemCache</strong></a>(self)</dt><dd><tt>Flushes the OS's file cache completely.<br> 121 <br> 122This function may require root or administrator access.</tt></dd></dl> 123 124<dl><dt><a name="AndroidPlatform-FlushSystemCacheForDirectory"><strong>FlushSystemCacheForDirectory</strong></a>(self, directory)</dt><dd><tt>Flushes the OS's file cache for the specified directory.<br> 125 <br> 126This function does not require root or administrator access.</tt></dd></dl> 127 128<dl><dt><a name="AndroidPlatform-GetArchName"><strong>GetArchName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="telemetry.core.platform.html#Platform">Platform</a> architecture.<br> 129 <br> 130Examples: x86_64 (posix), AMD64 (win), armeabi-v7a, x86</tt></dd></dl> 131 132<dl><dt><a name="AndroidPlatform-GetDeviceTypeName"><strong>GetDeviceTypeName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="telemetry.core.platform.html#Platform">Platform</a> device, or None.<br> 133 <br> 134Examples: Nexus 7, Nexus 6, Desktop</tt></dd></dl> 135 136<dl><dt><a name="AndroidPlatform-GetNetworkData"><strong>GetNetworkData</strong></a>(self, browser)</dt><dd><tt>Get current network data.<br> 137Returns:<br> 138 Tuple of (sent_data, received_data) in kb if data can be found,<br> 139 None otherwise.</tt></dd></dl> 140 141<dl><dt><a name="AndroidPlatform-GetOSName"><strong>GetOSName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="telemetry.core.platform.html#Platform">Platform</a> OS.<br> 142 <br> 143Examples: WIN, MAC, LINUX, CHROMEOS</tt></dd></dl> 144 145<dl><dt><a name="AndroidPlatform-GetOSVersionName"><strong>GetOSVersionName</strong></a>(self)</dt><dd><tt>Returns a logically sortable, string-like description of the <a href="telemetry.core.platform.html#Platform">Platform</a> OS<br> 146version.<br> 147 <br> 148Examples: VISTA, WIN7, LION, MOUNTAINLION</tt></dd></dl> 149 150<dl><dt><a name="AndroidPlatform-GetOSVersionNumber"><strong>GetOSVersionNumber</strong></a>(self)</dt><dd><tt>Returns an integer description of the <a href="telemetry.core.platform.html#Platform">Platform</a> OS major version.<br> 151 <br> 152Examples: On Mac, 13 for Mavericks, 14 for Yosemite.</tt></dd></dl> 153 154<dl><dt><a name="AndroidPlatform-HasBeenThermallyThrottled"><strong>HasBeenThermallyThrottled</strong></a>(self)</dt><dd><tt>Returns True if the device has been thermally throttled.</tt></dd></dl> 155 156<dl><dt><a name="AndroidPlatform-InstallApplication"><strong>InstallApplication</strong></a>(self, application)</dt><dd><tt>Installs the given application.</tt></dd></dl> 157 158<dl><dt><a name="AndroidPlatform-IsApplicationRunning"><strong>IsApplicationRunning</strong></a>(self, application)</dt><dd><tt>Returns whether an application is currently running.</tt></dd></dl> 159 160<dl><dt><a name="AndroidPlatform-IsCooperativeShutdownSupported"><strong>IsCooperativeShutdownSupported</strong></a>(self)</dt><dd><tt>Indicates whether CooperativelyShutdown, below, is supported.<br> 161It is not necessary to implement it on all platforms.</tt></dd></dl> 162 163<dl><dt><a name="AndroidPlatform-IsMonitoringPower"><strong>IsMonitoringPower</strong></a>(self)</dt><dd><tt>Returns true if power is currently being monitored, false otherwise.</tt></dd></dl> 164 165<dl><dt><a name="AndroidPlatform-IsThermallyThrottled"><strong>IsThermallyThrottled</strong></a>(self)</dt><dd><tt>Returns True if the device is currently thermally throttled.</tt></dd></dl> 166 167<dl><dt><a name="AndroidPlatform-LaunchApplication"><strong>LaunchApplication</strong></a>(self, application, parameters<font color="#909090">=None</font>, elevate_privilege<font color="#909090">=False</font>)</dt><dd><tt>"Launches the given |application| with a list of |parameters| on the OS.<br> 168 <br> 169Set |elevate_privilege| to launch the application with root or admin rights.<br> 170 <br> 171Returns:<br> 172 A popen style process handle for host platforms.</tt></dd></dl> 173 174<dl><dt><a name="AndroidPlatform-SetHTTPServerDirectories"><strong>SetHTTPServerDirectories</strong></a>(self, paths)</dt><dd><tt>Returns True if the HTTP server was started, False otherwise.</tt></dd></dl> 175 176<dl><dt><a name="AndroidPlatform-StartLocalServer"><strong>StartLocalServer</strong></a>(self, server)</dt><dd><tt>Starts a LocalServer and associates it with this platform.<br> 177|server.Close()| should be called manually to close the started server.</tt></dd></dl> 178 179<dl><dt><a name="AndroidPlatform-StartMonitoringPower"><strong>StartMonitoringPower</strong></a>(self, browser)</dt><dd><tt>Starts monitoring power utilization statistics.<br> 180 <br> 181Args:<br> 182 browser: The browser to monitor.</tt></dd></dl> 183 184<dl><dt><a name="AndroidPlatform-StartVideoCapture"><strong>StartVideoCapture</strong></a>(self, min_bitrate_mbps)</dt><dd><tt>Starts capturing video.<br> 185 <br> 186Outer framing may be included (from the OS, browser window, and webcam).<br> 187 <br> 188Args:<br> 189 min_bitrate_mbps: The minimum capture bitrate in MegaBits Per Second.<br> 190 The platform is free to deliver a higher bitrate if it can do so<br> 191 without increasing overhead.<br> 192 <br> 193Raises:<br> 194 ValueError if the required |min_bitrate_mbps| can't be achieved.</tt></dd></dl> 195 196<dl><dt><a name="AndroidPlatform-StopAllLocalServers"><strong>StopAllLocalServers</strong></a>(self)</dt></dl> 197 198<dl><dt><a name="AndroidPlatform-StopMonitoringPower"><strong>StopMonitoringPower</strong></a>(self)</dt><dd><tt>Stops monitoring power utilization and returns stats<br> 199 <br> 200Returns:<br> 201 None if power measurement failed for some reason, otherwise a dict of<br> 202 power utilization statistics containing: {<br> 203 # An identifier for the data provider. Allows to evaluate the precision<br> 204 # of the data. Example values: monsoon, powermetrics, ds2784<br> 205 'identifier': identifier,<br> 206 <br> 207 # The instantaneous power (voltage * current) reading in milliwatts at<br> 208 # each sample.<br> 209 'power_samples_mw': [mw0, mw1, ..., mwN],<br> 210 <br> 211 # The full system energy consumption during the sampling period in<br> 212 # milliwatt hours. May be estimated by integrating power samples or may<br> 213 # be exact on supported hardware.<br> 214 'energy_consumption_mwh': mwh,<br> 215 <br> 216 # The target application's energy consumption during the sampling period<br> 217 # in milliwatt hours. Should be returned iff<br> 218 # <a href="#AndroidPlatform-CanMeasurePerApplicationPower">CanMeasurePerApplicationPower</a>() return true.<br> 219 'application_energy_consumption_mwh': mwh,<br> 220 <br> 221 # A platform-specific dictionary of additional details about the<br> 222 # utilization of individual hardware components.<br> 223 component_utilization: {<br> 224 ...<br> 225 }<br> 226 # <a href="telemetry.core.platform.html#Platform">Platform</a>-specific data not attributed to any particular hardware<br> 227 # component.<br> 228 platform_info: {<br> 229 <br> 230 # Device-specific onboard temperature sensor.<br> 231 'average_temperature_c': c,<br> 232 <br> 233 ...<br> 234 }<br> 235 <br> 236 }</tt></dd></dl> 237 238<dl><dt><a name="AndroidPlatform-StopVideoCapture"><strong>StopVideoCapture</strong></a>(self)</dt><dd><tt>Stops capturing video.<br> 239 <br> 240Returns:<br> 241 A telemetry.core.video.Video object.</tt></dd></dl> 242 243<dl><dt><a name="AndroidPlatform-TakeScreenshot"><strong>TakeScreenshot</strong></a>(self, file_path)</dt><dd><tt>Takes a screenshot of the platform and save to |file_path|.<br> 244 <br> 245Note that this method may not be supported on all platform, so check with<br> 246CanTakeScreenshot before calling this.<br> 247 <br> 248Args:<br> 249 file_path: Where to save the screenshot to. If the platform is remote,<br> 250 |file_path| is the path on the host platform.<br> 251 <br> 252Returns True if it is believed the attempt succeeded.</tt></dd></dl> 253 254<hr> 255Data descriptors inherited from <a href="telemetry.core.platform.html#Platform">telemetry.core.platform.Platform</a>:<br> 256<dl><dt><strong>__dict__</strong></dt> 257<dd><tt>dictionary for instance variables (if defined)</tt></dd> 258</dl> 259<dl><dt><strong>__weakref__</strong></dt> 260<dd><tt>list of weak references to the object (if defined)</tt></dd> 261</dl> 262<dl><dt><strong>http_server</strong></dt> 263</dl> 264<dl><dt><strong>is_host_platform</strong></dt> 265</dl> 266<dl><dt><strong>local_servers</strong></dt> 267<dd><tt>Returns the currently running local servers.</tt></dd> 268</dl> 269<dl><dt><strong>network_controller</strong></dt> 270<dd><tt>Control network settings and servers to simulate the Web.</tt></dd> 271</dl> 272<dl><dt><strong>tracing_controller</strong></dt> 273</dl> 274</td></tr></table></td></tr></table> 275</body></html>