Bug 1552548 - Set screen brightness to 50% on reference phones for power tests. r=perftest-reviewers,stephendonner
authorGregory Mierzwinski <gmierz2@outlook.com>
Sat, 18 May 2019 14:01:05 +0000
changeset 536333 74c8824ac224b33b6617c9c3b54f08eb944be2a4
parent 536332 5142d8acf5e7a44966ddf03f08a4d03aac29ec7f
child 536334 ef9124d5d07fc1799ab0aa19a23998f119b43732
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperftest-reviewers, stephendonner
bugs1552548
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552548 - Set screen brightness to 50% on reference phones for power tests. r=perftest-reviewers,stephendonner This patch sets the screen brightness on the reference Moto G5 and Pixel 2 phones to 50% before starting power tests and resets it to its original value once the test is complete. Differential Revision: https://phabricator.services.mozilla.com/D31662
testing/raptor/raptor/power.py
--- a/testing/raptor/raptor/power.py
+++ b/testing/raptor/raptor/power.py
@@ -18,18 +18,28 @@ def init_android_power_test(raptor):
     # Set the screen-off timeout to two (2) hours, since the device will be running
     # disconnected, and would otherwise turn off the screen, thereby halting
     # execution of the test. Save the current value so we can restore it later
     # since it is a persistent change.
     raptor.screen_off_timeout = raptor.device.shell_output(
         "settings get system screen_off_timeout"
     ).strip()
     raptor.device.shell_output("settings put system screen_off_timeout 7200000")
+
+    # Set the screen brightness to ~50% for consistency of measurements across
+    # devices and save its current value to restore it later. Screen brightness
+    # values range from 0 to 255.
+    raptor.screen_brightness = raptor.device.shell_output(
+        "settings get system screen_brightness"
+    ).strip()
+    raptor.device.shell_output("settings put system screen_brightness 127")
+
     raptor.device.shell_output("dumpsys batterystats --reset")
     raptor.device.shell_output("dumpsys batterystats --enable full-wake-history")
+
     filepath = os.path.join(upload_dir, "battery-before.txt")
     with open(filepath, "w") as output:
         output.write(raptor.device.shell_output("dumpsys battery"))
 
 
 # The batterystats output for Estimated power use differs
 # for Android 7 and Android 8 and later.
 #
@@ -74,20 +84,24 @@ def init_android_power_test(raptor):
 
 def finish_android_power_test(raptor, test_name):
     upload_dir = os.getenv("MOZ_UPLOAD_DIR")
     if not upload_dir:
         raptor.log.critical(
             "% power test ignored because MOZ_UPLOAD_DIR was not set" % test_name
         )
         return
-    # Restore screen_off_timeout.
+    # Restore screen_off_timeout and screen brightness.
     raptor.device.shell_output(
         "settings put system screen_off_timeout %s" % raptor.screen_off_timeout
     )
+    raptor.device.shell_output(
+        "settings put system screen_brightness %s" % raptor.screen_brightness
+    )
+
     filepath = os.path.join(upload_dir, "battery-after.txt")
     with open(filepath, "w") as output:
         output.write(raptor.device.shell_output("dumpsys battery"))
     verbose = raptor.device._verbose
     raptor.device._verbose = False
     filepath = os.path.join(upload_dir, "batterystats.csv")
     with open(filepath, "w") as output:
         output.write(raptor.device.shell_output("dumpsys batterystats --checkin"))