[tradefed] Add a util method to fetch the Android first_api_level.

To be used for implementing notest/waiver filter based
on the property.

BUG=b:158951171
TEST=cheets_STS_R.CtsPermission still works

Change-Id: Id4fd8035eeffe6e073af8786fcb0304039584a25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2595565
Tested-by: Kazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Jiyoun Ha <jiyounha@chromium.org>
Reviewed-by: Jiyoun Ha <jiyounha@chromium.org>
Auto-Submit: Kazuhiro Inaba <kinaba@chromium.org>
diff --git a/server/hosts/cros_host.py b/server/hosts/cros_host.py
index 079b3f0..9110442 100644
--- a/server/hosts/cros_host.py
+++ b/server/hosts/cros_host.py
@@ -1521,21 +1521,27 @@
         """Start powerd if it isn't already running."""
         self.run('start powerd', ignore_status=True)
 
+    def _read_arc_prop_file(self, filename):
+        for path in [
+                '/usr/share/arcvm/properties/', '/usr/share/arc/properties/'
+        ]:
+            if self.path_exists(path + filename):
+                return utils.parse_cmd_output('cat ' + path + filename,
+                                              run_method=self.run)
+        return None
 
     def _get_arc_build_info(self):
         """Returns a dictionary mapping build properties to their values."""
         build_info = None
-        build_path_arcvm = '/usr/share/arcvm/properties/build.prop'
-        build_path_arc = '/usr/share/arc/properties/build.prop'
-        if self.path_exists(build_path_arcvm):
-            build_info = utils.parse_cmd_output('cat ' + build_path_arcvm,
-                                                run_method=self.run)
-        elif self.path_exists(build_path_arc):
-            build_info = utils.parse_cmd_output('cat ' + build_path_arc,
-                                                run_method=self.run)
-        if build_info == None:
-            logging.error('Failed to find build property info in device.')
-            return
+        for filename in ['build.prop', 'vendor_build.prop']:
+            properties = self._read_arc_prop_file(filename)
+            if properties:
+                if build_info:
+                    build_info.update(properties)
+                else:
+                    build_info = properties
+            else:
+                logging.error('Failed to find %s in device.', filename)
         return build_info
 
     def _get_arc_primary_abi(self):
@@ -1546,6 +1552,10 @@
         """Returns the security patch of the host."""
         return self._get_arc_build_info().get('ro.build.version.security_patch')
 
+    def get_arc_first_api_level(self):
+        """Returns the security patch of the host."""
+        return self._get_arc_build_info().get('ro.product.first_api_level')
+
     def _get_lsb_release_content(self):
         """Return the content of lsb-release file of host."""
         return self.run(