Give touch boost higher priority than idle detection
When the non-kernel idle timer is used, touch boost wasn't being applied
when the device was idle. I moved the code around to ensure touch boost
is applied when the device is idle.
Bug: 154571341
Test: - Wrote a new unit test to confirm correct idle behavior.
- Locally modified a Pixel 4 to use the regular idle timer rather
than the kernel idle timer, and confirmed we now apply touch
boost correctly.
Change-Id: Id998405a4d79f7a89fc0523b6503fe1a3dea8cce
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
index e8a7bef..2657dee 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
@@ -212,12 +212,14 @@
const RefreshRate& getRefreshRateForContent(const std::vector<LayerRequirement>& layers) const
EXCLUDES(mLock);
- // Returns the refresh rate that fits best to the given layers. This function also gets a
- // boolean flag that indicates whether user touched the screen recently to be factored in when
- // choosing the refresh rate and returns whether the refresh rate was chosen as a result of
- // a touch event.
- const RefreshRate& getRefreshRateForContentV2(const std::vector<LayerRequirement>& layers,
- bool touchActive, bool* touchConsidered) const
+ // Returns the refresh rate that fits best to the given layers.
+ // layers - The layer requirements to consider.
+ // touchActive - Whether the user touched the screen recently. Used to apply touch boost.
+ // idle - True if the system hasn't seen any buffers posted to layers recently.
+ // touchConsidered - An output param that tells the caller whether the refresh rate was chosen
+ // based on touch boost.
+ const RefreshRate& getBestRefreshRate(const std::vector<LayerRequirement>& layers,
+ bool touchActive, bool idle, bool* touchConsidered) const
EXCLUDES(mLock);
// Returns all the refresh rates supported by the device. This won't change at runtime.