Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: tools/telemetry/telemetry/core/platform/android_action_runner.py

Issue 1097463004: Add key_idle_power_cases for ensuring idle activity on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/browser_info.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/android_action_runner.py
diff --git a/tools/telemetry/telemetry/core/platform/android_action_runner.py b/tools/telemetry/telemetry/core/platform/android_action_runner.py
index 8728c9fdb733e3ec27ee60815c8a1cca3c41aaa7..c2f79b481a5760c13707fd4e665c8c9a5ada08b0 100644
--- a/tools/telemetry/telemetry/core/platform/android_action_runner.py
+++ b/tools/telemetry/telemetry/core/platform/android_action_runner.py
@@ -116,15 +116,28 @@ class AndroidActionRunner(object):
"""
self._platform_backend.adb.RunShellCommand('input roll %s %s' % (dx, dy))
+ def EnsureScreenOn(self):
+ """If device screen is off, turn screen on.
+ If the screen is already on, return immediately.
+
+ Raises:
+ Timeout: If the screen is off and device fails to turn screen on.
+ """
+ if self._platform_backend.IsScreenOn():
+ return
+
+ self._ToggleScreenOn()
+ util.WaitFor(self._platform_backend.IsScreenOn, 5)
+
def TurnScreenOn(self):
"""If device screen is off, turn screen on.
- If the screen is already on, this method returns immediately.
+ If the screen is already on, log a warning and return immediately.
Raises:
Timeout: If the screen is off and device fails to turn screen on.
"""
if not self._platform_backend.IsScreenOn():
- self._platform_backend.adb.RunShellCommand('input keyevent 26')
+ self._ToggleScreenOn()
else:
logging.warning('Screen on when expected off.')
return
@@ -133,7 +146,7 @@ class AndroidActionRunner(object):
def TurnScreenOff(self):
"""If device screen is on, turn screen off.
- If the screen is already off, this method returns immediately.
+ If the screen is already off, log a warning and return immediately.
Raises:
Timeout: If the screen is on and device fails to turn screen off.
@@ -142,8 +155,7 @@ class AndroidActionRunner(object):
return not self._platform_backend.IsScreenOn()
if self._platform_backend.IsScreenOn():
- self._platform_backend.adb.RunShellCommand(
- 'input keyevent 26')
+ self._ToggleScreenOn()
else:
logging.warning('Screen off when expected on.')
return
@@ -152,7 +164,7 @@ class AndroidActionRunner(object):
def UnlockScreen(self):
"""If device screen is locked, unlocks it.
- If the device is not locked, this method returns immediately.
+ If the device is not locked, log a warning and return immediately.
Raises:
Timeout: If device fails to unlock screen.
@@ -167,3 +179,6 @@ class AndroidActionRunner(object):
return
util.WaitFor(is_screen_unlocked, 5)
+
+ def _ToggleScreenOn(self):
+ self._platform_backend.adb.RunShellCommand('input keyevent 26')
« no previous file with comments | « tools/telemetry/telemetry/core/browser_info.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698