CameraITS: Turn off DUT screen at completion of test
am: ee81977f62

Change-Id: I0e3c7c99aca1dc68fc564c4c95528034ff63fe05
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 00e7433..3c9a9e6 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -304,6 +304,12 @@
                                       'turn_off_screen.py'), screen_id_arg]
         retcode = subprocess.call(cmd)
         assert retcode == 0
+        print 'Shutting down DUT screen: ', device_id
+        screen_id_arg = ('screen=%s' % device_id)
+        cmd = ['python', os.path.join(os.environ['CAMERA_ITS_TOP'], 'tools',
+                                      'turn_off_screen.py'), screen_id_arg]
+        retcode = subprocess.call(cmd)
+        assert retcode == 0
 
     print "ITS tests finished. Please go back to CtsVerifier and proceed"
 
diff --git a/apps/CameraITS/tools/turn_off_screen.py b/apps/CameraITS/tools/turn_off_screen.py
index 4163ab4..207042b 100644
--- a/apps/CameraITS/tools/turn_off_screen.py
+++ b/apps/CameraITS/tools/turn_off_screen.py
@@ -33,10 +33,10 @@
     process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
     cmd_ret = process.stdout.read()
     screen_state = re.split(r'[s|=]', cmd_ret)[-1]
-    if screen_state == 'OFF\n':
-        print 'Screen OFF. Turning ON.'
+    if 'OFF' in screen_state:
+        print 'Screen already OFF.'
     else:
-        wakeup = ('adb -s %s shell input keyevent POWER' % screen_id)
-        subprocess.Popen(wakeup.split())
+        pwrdn = ('adb -s %s shell input keyevent POWER' % screen_id)
+        subprocess.Popen(pwrdn.split())
 if __name__ == '__main__':
     main()