drm_hwcomposer: Only update vsync period when committed

Don't call VSyncWorker::SetVsyncPeriodNs on test-only commits; only
update it when the new mode is actually committed to the kernel
successfully.

Change-Id: I0445e15b5e2b902d1575c34cf296fee7fdc00028
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 6b676c2..f3c0fa0 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -695,8 +695,6 @@
                      .bottom = int(staged_config->mode.GetRawMode().vdisplay)});
 
     configs_.active_config_id = staged_mode_config_id_.value();
-    vsync_worker_->SetVsyncPeriodNs(staged_config->mode.GetVSyncPeriodNs());
-
     a_args.display_mode = staged_config->mode;
     if (!a_args.test_only) {
       mode_update_commited_ = true;
@@ -776,6 +774,11 @@
   }
 
   if (mode_update_commited_) {
+    const HwcDisplayConfig *new_config = GetCurrentConfig();
+    uint32_t new_vsync_period_ns = new_config
+                                       ? new_config->mode.GetVSyncPeriodNs()
+                                       : 0;
+    vsync_worker_->SetVsyncPeriodNs(new_vsync_period_ns);
     staged_mode_config_id_.reset();
     vsync_tracking_en_ = false;
     if (last_vsync_ts_ != 0) {