From 1101c358d0ddfc2a9fabb01aeec2780959fa2973 Mon Sep 17 00:00:00 2001
From: Marc Bonnici <marc.bonnici@arm.com>
Date: Wed, 10 Jan 2018 17:45:32 +0000
Subject: [PATCH] framework/rt_config: Add support for chromeos for some
 AndroidRTConfig

Allows setting of select android runtime configuration for devices running
chromeos and which support android. Currently only 'brightness' is functioning
correctly therefore the other parameters are only enable for standard android devices.
---
 wa/framework/target/runtime_config.py | 58 +++++++++++++++------------
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/wa/framework/target/runtime_config.py b/wa/framework/target/runtime_config.py
index 469503bd..6f62860b 100644
--- a/wa/framework/target/runtime_config.py
+++ b/wa/framework/target/runtime_config.py
@@ -844,7 +844,9 @@ class AndroidRuntimeConfig(RuntimeConfig):
         super(AndroidRuntimeConfig, self).__init__(target)
 
     def initialize(self):
-        if self.target.os != 'android':
+        if self.target.os not in ['android', 'chromeos']:
+            return
+        if self.target.os == 'chromeos' and not self.target.supports_android:
             return
 
         param_name = 'brightness'
@@ -857,33 +859,39 @@ class AndroidRuntimeConfig(RuntimeConfig):
                               Specify the screen brightness to be set for
                               the device
                               """)
-        param_name = 'airplane_mode'
-        self._runtime_params[param_name] = \
-            RuntimeParameter(param_name, kind=bool,
-                              setter=self.set_airplane_mode,
-                              description="""
-                              Specify whether airplane mode should be
-                              enabled for the device
-                              """)
-        param_name = 'rotation'
-        self._runtime_params[param_name] = \
-            RuntimeParameter(param_name, kind=ScreenOrientation,
-                              setter=self.set_rotation,
-                              description="""
-                              Specify the screen orientation for the device
-                              """)
-        param_name = 'screen_on'
-        self._runtime_params[param_name] = \
-            RuntimeParameter(param_name, kind=bool,
-                              default=True,
-                              setter=self.set_screen_state,
-                              description="""
-                              Specify whether the device screen should be on
-                              """)
+
+        if self.target.os is 'android':
+            param_name = 'airplane_mode'
+            self._runtime_params[param_name] = \
+                RuntimeParameter(param_name, kind=bool,
+                                  setter=self.set_airplane_mode,
+                                  description="""
+                                  Specify whether airplane mode should be
+                                  enabled for the device
+                                  """)
+
+            param_name = 'rotation'
+            self._runtime_params[param_name] = \
+                RuntimeParameter(param_name, kind=ScreenOrientation,
+                                  setter=self.set_rotation,
+                                  description="""
+                                  Specify the screen orientation for the device
+                                  """)
+
+            param_name = 'screen_on'
+            self._runtime_params[param_name] = \
+                RuntimeParameter(param_name, kind=bool,
+                                  default=True,
+                                  setter=self.set_screen_state,
+                                  description="""
+                                  Specify whether the device screen should be on
+                                  """)
 
     def check_target(self):
-        if self.target.os != 'android':
+        if self.target.os != 'android' and self.target.os != 'chromeos':
             raise ConfigError('Target does not appear to be running Android')
+        if self.target.os == 'chromeos' and not self.target.supports_android:
+            raise ConfigError('Target does not appear to support Android')
 
     def validate_parameters(self):
         pass