Fix screen dimensions for portrait devices

This commit is contained in:
Cameron Gutman 2017-11-21 20:18:28 -08:00
parent bfa5a6349e
commit f2d122a275

View File

@ -124,12 +124,17 @@ public class StreamSettings extends Activity {
// AVC supported width range: 64 - 384 // AVC supported width range: 64 - 384
// HEVC supported width range: 64 - 544 // HEVC supported width range: 64 - 544
for (Display.Mode candidate : display.getSupportedModes()) { for (Display.Mode candidate : display.getSupportedModes()) {
if ((candidate.getPhysicalWidth() >= 3840 || candidate.getPhysicalHeight() >= 2160) && // Some devices report their dimensions in the portrait orientation
maxSupportedResW < 3840) { // where height > width. Normalize these to the conventional width > height
// arrangement before we process them.
int width = Math.max(candidate.getPhysicalWidth(), candidate.getPhysicalHeight());
int height = Math.min(candidate.getPhysicalWidth(), candidate.getPhysicalHeight());
if ((width >= 3840 || height >= 2160) && maxSupportedResW < 3840) {
maxSupportedResW = 3840; maxSupportedResW = 3840;
} }
else if ((candidate.getPhysicalWidth() >= 1920 || candidate.getPhysicalHeight() >= 1080) && else if ((width >= 1920 || height >= 1080) && maxSupportedResW < 1920) {
maxSupportedResW < 1920) {
maxSupportedResW = 1920; maxSupportedResW = 1920;
} }
} }