Remove max API level for reading TV resolution from system properties

PiperOrigin-RevId: 394415421
This commit is contained in:
olly 2021-09-02 10:37:03 +01:00 committed by bachinger
parent 0d4986f806
commit 68eff51d96

View File

@ -2277,21 +2277,20 @@ public final class Util {
* @return The size of the current mode, in pixels. * @return The size of the current mode, in pixels.
*/ */
public static Point getCurrentDisplayModeSize(Context context, Display display) { public static Point getCurrentDisplayModeSize(Context context, Display display) {
if (Util.SDK_INT <= 29 && display.getDisplayId() == Display.DEFAULT_DISPLAY && isTv(context)) { if (display.getDisplayId() == Display.DEFAULT_DISPLAY && isTv(context)) {
// On Android TVs it is common for the UI to be configured for a lower resolution than // On Android TVs it's common for the UI to be driven at a lower resolution than the physical
// SurfaceViews can output. Before API 26 the Display object does not provide a way to // resolution of the display (e.g., driving the UI at 1080p when the display is 4K).
// identify this case, and up to and including API 28 many devices still do not correctly set // SurfaceView outputs are still able to use the full physical resolution on such devices.
// their hardware compositor output size. //
// Prior to API level 26, the Display object did not provide a way to obtain the true physical
// Sony Android TVs advertise support for 4k output via a system feature. // resolution of the display. From API level 26, Display.getMode().getPhysical[Width|Height]
if ("Sony".equals(Util.MANUFACTURER) // is expected to return the display's true physical resolution, but we still see devices
&& Util.MODEL.startsWith("BRAVIA") // setting their hardware compositor output size incorrectly, which makes this unreliable.
&& context.getPackageManager().hasSystemFeature("com.sony.dtv.hardware.panel.qfhd")) { // Hence for TV devices, we try and read the display's true physical resolution from system
return new Point(3840, 2160); // properties.
} //
// From API level 28, Treble may prevent the system from writing sys.display-size, so we check
// Otherwise check the system property for display size. From API 28 treble may prevent the // vendor.display-size instead.
// system from writing sys.display-size so we check vendor.display-size instead.
@Nullable @Nullable
String displaySize = String displaySize =
Util.SDK_INT < 28 Util.SDK_INT < 28
@ -2313,6 +2312,13 @@ public final class Util {
} }
Log.e(TAG, "Invalid display size: " + displaySize); Log.e(TAG, "Invalid display size: " + displaySize);
} }
// Sony Android TVs advertise support for 4k output via a system feature.
if ("Sony".equals(Util.MANUFACTURER)
&& Util.MODEL.startsWith("BRAVIA")
&& context.getPackageManager().hasSystemFeature("com.sony.dtv.hardware.panel.qfhd")) {
return new Point(3840, 2160);
}
} }
Point displaySize = new Point(); Point displaySize = new Point();