SF: change the render frame rate when a display mode is changing

Set the render frame rate to the physical display refresh rate so
we could schedule the frame that initiates the mode switch quicker.

Test: atest open-fixed-calculator --rebuild-module-info --tf-template metric_post_processor=google/template/postprocessors/metric-file-aggregate.xml --aggregate-metric-filter source_event_delay_millis_com.google.android.calculator-mean
Bug: 264964129
Change-Id: Ib25ac71837d73284e7b4b4c89d98f412922693b3
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e8dc7d4..40de4d6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1152,6 +1152,10 @@
     switch (display->setDesiredActiveMode(DisplayDevice::ActiveModeInfo(std::move(request)),
                                           force)) {
         case DisplayDevice::DesiredActiveModeAction::InitiateDisplayModeSwitch:
+            // Set the render rate as setDesiredActiveMode updated it.
+            mScheduler->setRenderRate(display->refreshRateSelector().getActiveMode().fps);
+
+            // Schedule a new frame to initiate the display mode switch.
             scheduleComposite(FrameHint::kNone);
 
             // Start receiving vsync samples now, so that we can detect a period