Add logic to actually read OBD2 sensor properties to VehicleHidlTest

Test: make vts BUILD_GOOGLE_VTS=true -j32 && vts-tradefed run commandAndExit vts --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VehicleHidlTest -l INFO

Change-Id: I0817823ea00354b27c90bdd412012320868b9e8f
diff --git a/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py b/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py
index 8d786e7..7854c7b 100644
--- a/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py
+++ b/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py
@@ -108,19 +108,89 @@
                 break
         return isLiveSupported, isFreezeSupported
 
+    def readVhalProperty(self, propertyId, areaId=0):
+        """Reads a specified property from Vehicle HAL.
+
+        Args:
+            propertyId: the numeric identifier of the property to be read.
+            areaId: the numeric identifier of the vehicle area to retrieve the
+                    property for. 0, or omitted, for global.
+
+        Returns:
+            the value of the property as read from Vehicle HAL, or None
+            if it could not read successfully.
+        """
+        vp_dict = {
+            'prop' : propertyId,
+            'timestamp' : 0,
+            'areaId' : areaId,
+            'value' : {
+                'int32Values' : [],
+                'floatValues' : [],
+                'int64Values' : [],
+                'bytes' : [],
+                'stringValue' : ""
+            }
+        }
+        vp = self.vtypes.Py2Pb("VehiclePropValue", vp_dict)
+        status, value = self.vehicle.get(vp)
+        if self.vtypes.OK == status:
+            return value
+        else:
+            logging.warning("attempt to read property %s returned error %d",
+                            propertyId, status)
+
     def testObd2SensorProperties(self):
         """Test reading the live and freeze OBD2 frame properties.
 
         OBD2 (On-Board Diagnostics 2) is the industry standard protocol
         for retrieving diagnostic sensor information from vehicles.
         """
+        class CheckRead(object):
+            """This class wraps the logic of an actual property read.
+
+            Attributes:
+                testobject: the test case this object is used on behalf of.
+                propertyId: the identifier of the Vehiche HAL property to read.
+                name: the engineer-readable name of this test operation.
+            """
+
+            def __init__(self, testobject, propertyId, name):
+                self.testobject = testobject
+                self.propertyId = propertyId
+                self.name = name
+
+            def onReadSuccess(self, propValue):
+                """Override this to perform any post-read validation.
+
+                Args:
+                    propValue: the property value obtained from Vehicle HAL.
+                """
+                pass
+
+            def __call__(self):
+                """Reads the specified property and validates the result."""
+                propValue = self.testobject.readVhalProperty(self.propertyId)
+                asserts.assertNotEqual(propValue, None,
+                                       msg="reading %s should not return None" %
+                                       self.name)
+                logging.info("%s = %s", self.name, propValue)
+                self.onReadSuccess(propValue)
+                logging.info("%s pass" % self.name)
+
         def checkLiveFrameRead():
             """Validates reading the OBD2_LIVE_FRAME (if available)."""
-            logging.info("checkLiveFrameRead no-op pass")
+            checker = CheckRead(self,
+                                self.vtypes.OBD2_LIVE_FRAME,
+                                "OBD2_LIVE_FRAME")
+            checker()
 
         def checkFreezeFrameRead():
             """Validates reading the OBD2_FREEZE_FRAME (if available)."""
-            logging.info("checkLiveFrameRead no-op pass")
+            checker = CheckRead(self,
+                                self.vtypes.OBD2_FREEZE_FRAME,
+                                "OBD2_FREEZE_FRAME")
+            checker()
 
         isLiveSupported, isFreezeSupported = self.getSupportInfo()
         logging.info("isLiveSupported = %s, isFreezeSupported = %s",