Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

FP5: Introduce priv-app to control refresh rate switching

Description

Introduce RefreshRateController priv-app to fix discrepancy between preferred refresh rate set in settings and actual refresh rate.

Screenshots

Technical details

On FP5, min_refresh_rate selected through Settings via MinRefreshRatePreferenceController does not get honored after display state change (screen on / off).

On FPOS, which uses QTI/Qualcomm components for SurfaceFlinger, they have specific handling in QtiExtension.

FPOS handles refresh rate switching as follows:

  • User sets preferred refresh rate
  • User toggles screen state (on / off)
  • QTI SurfaceFlinger Extensions restore preferred refresh rate after a 5 second delay

Since modifying SurfaceFlinger to add QTI Extensions is too broad scope, we handle our needs through a priv-app which runs a service at boot.

Through testing, it was noted that in order to force a display state change to the proper refresh rate, we have to:

  • Set min_refresh_rate key to 0f
  • Set min_refresh_rate key to preferred refresh rate

Our RefreshRateController priv-app:

  • Listens for ACTION_LOCKED_BOOT_COMPLETED event in RefreshRateBroadcastReceiver
  • Triggers RefreshRateMonitoringService, which handles setting and restoring min_refresh_rate

RefreshRateMonitoringService also implements DisplayManager.DisplayListener class and does following:

  • On service creation, register listener for tracking display mode and state changes
  • Initializes internal global variables which keep track of display mode, state, min_fps & refresh rate switching progress.

If min_refresh_rate is not present, it will get current refresh rate and set min_refresh_rate to that refresh rate.
This is for handling case when min_refresh_rate key is missing due to any unexpected reasons.

In normal case, when user sets preferred refresh rate through settings, min_refresh_rate is populated and retained across reboots.

Whenever display turns on, our service will reset and set min_refresh_rate key to value user has chosen.
This forces a display mode change and successfully applies preferred refresh rate.

Setting the preferred refresh rate into min_refresh_rate is done after 250ms of resetting min_refresh_rate to allow mode change to fully propagate.

Tests

Set Minimum refresh rate in Settings -> Display to 60hz

  • Observe refresh rate through testufo.com and through manual testing by interacting with UI
  • Lock and unlock screen and check refresh rate
  • Reboot device and check refresh rate

Set Minimum refresh rate in Settings -> Display to 90hz

  • Observe refresh rate through testufo.com and through manual testing by interacting with UI
  • Lock and unlock screen and check refresh rate
  • Reboot device and check refresh rate

Issues

https://gitlab.e.foundation/e/backlog/-/issues/7590

10 commandments of code review

👪 ❤️ https://gitlab.e.foundation/groups/e/-/wikis/contribute/development-processes/code-review-guidelines

Merge request reports

Loading