From a5f3ca1a06773d5b5c2ce707c32fd23ddaeceadb Mon Sep 17 00:00:00 2001 From: Snild Dolkow Date: Thu, 21 Oct 2021 18:33:21 +0200 Subject: [PATCH] Update display mode when setting mAlwaysRespectAppRequest setShouldAlwaysRespectAppRequestedMode() is called from tests to make DisplayModeDirector.getDesiredDisplayModeSpecs() to ignore non-app votes. However, the set boolean will have no effect until something triggers a call to that getter. This caused MatchContentFrameRateTest#testMatchContentFramerate_Auto to fail on devices with a lower-than-max peak_refresh_rate setting (or the fallback resource config_defaultPeakRefreshRate): its setFrameRate() call doesn't trigger a call to updateRefreshRateSettingLocked() or any other vote update, so the lower peak value is still in effect in parts of the system. Notify the 'desired specs' listener when changing the bool will allow the new mAlwaysRespectAppRequest value to properly take effect. Any multi-refresh-rate device should be able to reproduce like so: $ adb shell 'settings put system peak_refresh_rate 60' On userdebug, you can overlay config_defaultPeakRefreshRate instead: $ adb root $ adb shell 'settings put system peak_refresh_rate ""' # remove setting $ adb shell cmd overlay fabricate --target android \ --name DefaultPeak60 \ android:integer/config_defaultPeakRefreshRate 0x10 60 $ adb shell cmd overlay enable com.android.shell:DefaultPeak60 $ adb shell stop $ adb shell start # so system_server loads the new resource value $ adb shell cmd overlay lookup android \ android:integer/config_defaultPeakRefreshRate # should output "60" Bug: 204048977 Test: run cts -m CtsGraphicsTestCases -t android.graphics.cts.MatchContentFrameRateTest#testMatchContentFramerate_Auto Change-Id: Ic6c2024ab1067ad7ba821190fe05009dac79b929 --- .../java/com/android/server/display/DisplayModeDirector.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/display/DisplayModeDirector.java b/services/core/java/com/android/server/display/DisplayModeDirector.java index d66d7ee99f2e6..329a69634f71f 100644 --- a/services/core/java/com/android/server/display/DisplayModeDirector.java +++ b/services/core/java/com/android/server/display/DisplayModeDirector.java @@ -512,7 +512,10 @@ public class DisplayModeDirector { */ public void setShouldAlwaysRespectAppRequestedMode(boolean enabled) { synchronized (mLock) { - mAlwaysRespectAppRequest = enabled; + if (mAlwaysRespectAppRequest != enabled) { + mAlwaysRespectAppRequest = enabled; + notifyDesiredDisplayModeSpecsChangedLocked(); + } } }