Apply Vhal Handler to Surround View Service

Bug: 153735481
Test: Manually launched SV service and app on Osprey
Change-Id: I285c4698505e0072ee8251d927a0ef4dac2f2a78
diff --git a/surround_view/service-impl/SurroundView3dSession.cpp b/surround_view/service-impl/SurroundView3dSession.cpp
index 97af815..a06a260 100644
--- a/surround_view/service-impl/SurroundView3dSession.cpp
+++ b/surround_view/service-impl/SurroundView3dSession.cpp
@@ -165,9 +165,10 @@
     }
 }
 
-SurroundView3dSession::SurroundView3dSession(sp<IEvsEnumerator> pEvs)
-    : mEvs(pEvs),
-      mStreamState(STOPPED) {
+SurroundView3dSession::SurroundView3dSession(sp<IEvsEnumerator> pEvs, VhalHandler* vhalHandler) :
+      mEvs(pEvs),
+      mStreamState(STOPPED),
+      mVhalHandler(vhalHandler) {
     mEvsCameraIds = {"0" , "1", "2", "3"};
 }
 
@@ -217,6 +218,14 @@
     sequenceId = 0;
     startEvs();
 
+    if (mVhalHandler != nullptr) {
+        if (!mVhalHandler->startPropertiesUpdate()) {
+            LOG(WARNING) << "VhalHandler cannot be started properly";
+        }
+    } else {
+        LOG(WARNING) << "VhalHandler is null. Ignored";
+    }
+
     // TODO(b/158131080): the STREAM_STARTED event is not implemented in EVS
     // reference implementation yet. Once implemented, this logic should be
     // moved to EVS notify callback.
@@ -237,6 +246,12 @@
     LOG(DEBUG) << __FUNCTION__;
     unique_lock <mutex> lock(mAccessLock);
 
+    if (mVhalHandler != nullptr) {
+        mVhalHandler->stopPropertiesUpdate();
+    } else {
+        LOG(WARNING) << "VhalHandler is null. Ignored";
+    }
+
     if (mStreamState == RUNNING) {
         // Tell the processFrames loop to stop processing frames
         mStreamState = STOPPING;
@@ -481,6 +496,15 @@
             matrix[i][j] = kRecViews[recViewId][i*4+j];
     }
 
+    // Get the latest VHal property values
+    if (mVhalHandler != nullptr) {
+        if (!mVhalHandler->getPropertyValues(&mPropertyValues)) {
+            LOG(ERROR) << "Failed to get property values";
+        }
+    } else {
+        LOG(WARNING) << "VhalHandler is null. Ignored";
+    }
+
     if (mSurroundView->Get3dSurroundView(
         mInputPointers, matrix, &mOutputPointer)) {
         LOG(INFO) << "Get3dSurroundView succeeded";