From 8d914d967ccc15afa95f140ab028a1d9e6b07b64 Mon Sep 17 00:00:00 2001 From: zarzet Date: Mon, 13 Jul 2026 20:29:10 +0700 Subject: [PATCH] feat(android): request highest display refresh rate at current resolution --- .../kotlin/com/zarz/spotiflac/MainActivity.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/android/app/src/main/kotlin/com/zarz/spotiflac/MainActivity.kt b/android/app/src/main/kotlin/com/zarz/spotiflac/MainActivity.kt index 58daa22a..d2c7511d 100644 --- a/android/app/src/main/kotlin/com/zarz/spotiflac/MainActivity.kt +++ b/android/app/src/main/kotlin/com/zarz/spotiflac/MainActivity.kt @@ -1962,9 +1962,31 @@ class MainActivity: FlutterFragmentActivity() { // delegate looks it up by cached id (see getCachedEngineId above). AudioServicePlugin.getFlutterEngine(this) super.onCreate(savedInstanceState) + requestHighRefreshRate() handleExtensionOAuthIntent(intent) } + // Flutter does not request a display mode, so many devices keep the + // activity at 60Hz even on 90/120Hz panels. Prefer the highest refresh + // rate available at the current resolution. + private fun requestHighRefreshRate() { + val display = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) display + else @Suppress("DEPRECATION") windowManager.defaultDisplay + val current = display?.mode ?: return + val best = display.supportedModes + .filter { + it.physicalWidth == current.physicalWidth && + it.physicalHeight == current.physicalHeight + } + .maxByOrNull { it.refreshRate } ?: return + if (best.modeId != current.modeId) { + window.attributes = window.attributes.apply { + preferredDisplayModeId = best.modeId + } + } + } + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent)