[automerger skipped] DO NOT MERGE - Merge RQ3A.210605.005 am: 8e972379a0 -s ours

am skip reason: skipped by user delphij

Original change: https://android-review.googlesource.com/c/device/google/trout/+/1740178

Change-Id: Iac4375d933438ac54268ca4cca90cda82082773d
diff --git a/hal/vehicle/2.0/Android.bp b/hal/vehicle/2.0/Android.bp
index e72a9ea..b4ba58b 100644
--- a/hal/vehicle/2.0/Android.bp
+++ b/hal/vehicle/2.0/Android.bp
@@ -148,7 +148,6 @@
     vendor: true,
     relative_install_path: "hw",
     srcs: [
-        "GrpcVehicleClient.cpp",
         "VirtualizedVehicleService.cpp",
         "WatchdogClient.cpp",
     ],
@@ -161,6 +160,7 @@
         "libgrpc++",
     ],
     static_libs: [
+        "android.hardware.automotive.vehicle@2.0-virtualization-client-lib",
         "android.hardware.automotive.utils.vsockinfo",
         "android.hardware.automotive.vehicle@2.0-manager-lib",
         "android.hardware.automotive.vehicle@2.0-default-impl-lib",
diff --git a/hal/vehicle/2.0/GarageModeServerSideHandler.cpp b/hal/vehicle/2.0/GarageModeServerSideHandler.cpp
index b19b1df..60c36bf 100644
--- a/hal/vehicle/2.0/GarageModeServerSideHandler.cpp
+++ b/hal/vehicle/2.0/GarageModeServerSideHandler.cpp
@@ -146,19 +146,20 @@
         return;
     }
 
-    int watchDescriptor = inotify_add_watch(inotifyFd, mPowerStateMarkerPath.c_str(), IN_MODIFY);
-    if (watchDescriptor < 0) {
-        LOG(ERROR) << __func__ << ": failed to watch file " << mPowerStateMarkerPath << " : "
-                   << strerror(errno);
-        return;
-    }
-
     alignas(alignof(struct inotify_event)) char inotifyEventBuffer[4096] = {0};
     [[maybe_unused]] struct inotify_event& inotifyEvent =
             *reinterpret_cast<struct inotify_event*>(inotifyEventBuffer);
 
     HandleNewPowerState();
     while (!mShuttingDownFlag.load()) {
+        int watchDescriptor =
+                inotify_add_watch(inotifyFd, mPowerStateMarkerPath.c_str(), IN_MODIFY);
+        if (watchDescriptor < 0) {
+            LOG(ERROR) << __func__ << ": failed to watch file " << mPowerStateMarkerPath << " : "
+                       << strerror(errno);
+            return;
+        }
+
         if (!WaitForReadWithTimeout(inotifyFd, kFileStatusCheckPeriod)) {
             continue;
         }