ITS: add KEYCODE_POWER to reset dimmer timer.

bug: 179678537
Change-Id: I6ab0b32807a301d2086bd240bdcc800be70031e8
diff --git a/apps/CameraITS2.0/tests/its_base_test.py b/apps/CameraITS2.0/tests/its_base_test.py
index 86dfefc..1f96200 100644
--- a/apps/CameraITS2.0/tests/its_base_test.py
+++ b/apps/CameraITS2.0/tests/its_base_test.py
@@ -24,7 +24,8 @@
 import its_session_utils
 
 ADAPTIVE_BRIGHTNESS_OFF = '0'
-DISPLAY_TIMEOUT = 1800000  # ms
+TABLET_CMD_DELAY_SEC = 0.5  # found empirically
+TABLET_DIMMER_TIMEOUT_MS = 1800000  # this is max setting possible
 CTS_VERIFIER_PKG = 'com.android.cts.verifier'
 MBS_PKG_TXT = 'mbs'
 MBS_PKG = 'com.google.android.mobly.snippet.bundled'
@@ -136,7 +137,11 @@
     time.sleep(WAIT_TIME_SEC)
 
   def setup_tablet(self):
+    # KEYCODE_POWER to reset dimmer timer. KEYCODE_WAKEUP no effect if ON.
+    self.tablet.adb.shell(['input', 'keyevent', 'KEYCODE_POWER'])
+    time.sleep(TABLET_CMD_DELAY_SEC)
     self.tablet.adb.shell(['input', 'keyevent', 'KEYCODE_WAKEUP'])
+    time.sleep(TABLET_CMD_DELAY_SEC)
     # Turn off the adaptive brightness on tablet.
     self.tablet.adb.shell(
         ['settings', 'put', 'system', 'screen_brightness_mode',
@@ -148,7 +153,7 @@
     logging.debug('Tablet brightness set to: %s',
                   format(self.tablet_screen_brightness))
     self.tablet.adb.shell('settings put system screen_off_timeout {}'.format(
-        DISPLAY_TIMEOUT))
+        TABLET_DIMMER_TIMEOUT_MS))
     self.tablet.adb.shell('am force-stop com.google.android.apps.docs')
 
   def parse_hidden_camera_id(self):