SurfaceFlinger: Query Scheduler when updating allowed display configs

Currently two entities in SurfaceFlinger can set a new display refresh
rate: (1) SurfaceFlinger core, and (2) Scheduler. It's possible for
these two entities to get out of sync in the following way:
1) Scheduler updates the refresh rate to some rate
2) Upper layers call into SurfaceFlinger to update allowed display
3) SurfaceFlinger always sets display rate to max

If the refresh rate from #1 and #3 don't match, it can leave the system
in an inconsistent state, potentially causing visual and power issues.

This change fixes this problem by changing step #3: Instead of always
choosing the max refresh rate, SurfaceFlinger queries the optimal
refresh rate from Scheduler. If that rate isn't available, only then
does SurfaceFlinger default to the maximum rate.

Bug: 139557239
Test: atest libsurfaceflinger_unittest
Test: Manual:
    1) Start with SurfaceFlinger idling (Scheduler selected
    2) Trigger a change in allowed display configs from
    3) Make sure the RefreshRateType SurfaceFlinger sets is DEFAULT
    instead of PERFORMANCE
Change-Id: Ia85a60fde55afaed5106462942e0bb77652ec737
Merged-In: Ia85a60fde55afaed5106462942e0bb77652ec737
(cherry picked from commit d916d941d89ec8fdcbc2bbe0bfdf0b0db1ad08b5)
4 files changed