From d113878613e1269278ba9decab5bb40710ef9851 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 21 Mar 2020 13:43:59 -0700 Subject: [PATCH] Use current display refresh rate only for non-TV devices --- app/src/main/java/com/limelight/Game.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 2f80e0c0..d0d6057f 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -43,6 +43,7 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; @@ -731,7 +732,18 @@ public class Game extends Activity implements SurfaceHolder.Callback, streamView.setDesiredAspectRatio((double)prefConfig.width / (double)prefConfig.height); } - return displayRefreshRate; + if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION) || + getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) { + // TVs may take a few moments to switch refresh rates, and we can probably assume + // it will be eventually activated. + // TODO: Improve this + return displayRefreshRate; + } + else { + // Use the actual refresh rate of the display, since the preferred refresh rate or mode + // may not actually be applied (ex: Pixel 4 with Smooth Display disabled). + return getWindowManager().getDefaultDisplay().getRefreshRate(); + } } @SuppressLint("InlinedApi")