From 5aa5b6cbf49fc0df22c9c7befa089c178cdf643f Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Mon, 29 Apr 2019 17:19:05 -0700 Subject: [PATCH] VirtualDisplay size constraint - add a comment explaining the reason (#8780) * VirtualDisplay size: add a comment explaining the reason Address nits in: https://github.com/flutter/engine/pull/8704 * remove locale import --- .../plugin/platform/PlatformViewsController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 2561897bd85..08c378d3370 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.nio.ByteBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; /** @@ -416,15 +415,16 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler, 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: " + + "[" + width + ", " + height + "]" + + " is not supported. It is larger than the device screen size: " + + "[" + metrics.widthPixels + ", " + metrics.heightPixels + "]."; + throw new IllegalArgumentException(error); } }