OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os |
| 6 import sys |
| 7 |
| 8 # Get build/android scripts into our path. |
| 9 sys.path.append( |
| 10 os.path.abspath( |
| 11 os.path.join(os.path.dirname(__file__), |
| 12 '../../../build/android'))) |
| 13 |
| 14 from pylib import perf_tests_helper # pylint: disable=F0401 |
| 15 from pylib import thermal_throttle # pylint: disable=F0401 |
| 16 |
| 17 try: |
| 18 from pylib import surface_stats_collector # pylint: disable=F0401 |
| 19 except Exception: |
| 20 surface_stats_collector = None |
| 21 |
| 22 |
| 23 class AndroidPlatformBackend(object): |
| 24 def __init__(self, adb, window_package, window_activity): |
| 25 super(AndroidPlatformBackend, self).__init__() |
| 26 self._adb = adb |
| 27 self._window_package = window_package |
| 28 self._window_activity = window_activity |
| 29 self._surface_stats_collector = None |
| 30 self._perf_tests_setup = perf_tests_helper.PerfTestSetup(self._adb) |
| 31 self._thermal_throttle = thermal_throttle.ThermalThrottle(self._adb) |
| 32 |
| 33 def IsRawDisplayFrameRateSupported(self): |
| 34 return True |
| 35 |
| 36 def StartRawDisplayFrameRateMeasurement(self, trace_tag): |
| 37 assert not self._surface_stats_collector |
| 38 self._surface_stats_collector = \ |
| 39 surface_stats_collector.SurfaceStatsCollector( |
| 40 self._adb, self._window_package, self._window_activity, trace_tag) |
| 41 self._surface_stats_collector.__enter__() |
| 42 |
| 43 def StopRawDisplayFrameRateMeasurement(self): |
| 44 self._surface_stats_collector.__exit__() |
| 45 self._surface_stats_collector = None |
| 46 |
| 47 def SetFullPerformanceModeEnabled(self, enabled): |
| 48 if enabled: |
| 49 self._perf_tests_setup.SetUp() |
| 50 else: |
| 51 self._perf_tests_setup.TearDown() |
| 52 |
| 53 def CanMonitorThermalThrottling(self): |
| 54 return True |
| 55 |
| 56 def IsThermallyThrottled(self): |
| 57 return self._thermal_throttle.IsThrottled() |
| 58 |
| 59 def HasBeenThermallyThrottled(self): |
| 60 return self._thermal_throttle.HasBeenThrottled() |
OLD | NEW |