From 9f7c6d432225073f00fc137d512ee3bd6d46909b Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Mon, 29 Apr 2019 16:04:00 -0700 Subject: [PATCH 1/2] VirtualDisplay size: add a comment explaining the reason Address nits in: https://github.com/flutter/engine/pull/8704 --- .../plugin/platform/PlatformViewsController.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 2561897bd8506..3d8590d2274e1 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -416,15 +416,16 @@ private static PointerCoords parsePointerCoords(Object rawCoords, float density) return coords; } + // Creating a VirtualDisplay larger than the size of the device screen size + // could cause the device to restart: https://github.com/flutter/flutter/issues/28978 private void validateVirtualDisplayDimensions(int width, int height) { DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); if (height > metrics.heightPixels || width > metrics.widthPixels) { - StringBuilder errorBuilder = new StringBuilder(); - errorBuilder.append("Creating a virtual display of size: "); - errorBuilder.append(String.format(Locale.ENGLISH, "[%d, %d], ", width, height)); - errorBuilder.append(" is not supported. It is larger than the device screen size: "); - errorBuilder.append(String.format(Locale.ENGLISH, "[%d, %d].", metrics.widthPixels, metrics.heightPixels)); - throw new IllegalArgumentException(errorBuilder.toString()); + String error = "Creating a virtual display of size: " + + String.format(Locale.ENGLISH, "[%d, %d], ", width, height) + + " is not supported. It is larger than the device screen size: " + + String.format(Locale.ENGLISH, "[%d, %d].", metrics.widthPixels, metrics.heightPixels); + throw new IllegalArgumentException(error); } } From 93f24df886ada866268eaee4635289941c5cdd75 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Mon, 29 Apr 2019 16:14:18 -0700 Subject: [PATCH 2/2] remove locale import --- .../io/flutter/plugin/platform/PlatformViewsController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 3d8590d2274e1..08c378d337084 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; /** @@ -422,9 +421,9 @@ private void validateVirtualDisplayDimensions(int width, int height) { DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); if (height > metrics.heightPixels || width > metrics.widthPixels) { String error = "Creating a virtual display of size: " - + String.format(Locale.ENGLISH, "[%d, %d], ", width, height) + + "[" + width + ", " + height + "]" + " is not supported. It is larger than the device screen size: " - + String.format(Locale.ENGLISH, "[%d, %d].", metrics.widthPixels, metrics.heightPixels); + + "[" + metrics.widthPixels + ", " + metrics.heightPixels + "]."; throw new IllegalArgumentException(error); } }