diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 2561897bd8506..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; /** @@ -416,15 +415,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: " + + "[" + width + ", " + height + "]" + + " is not supported. It is larger than the device screen size: " + + "[" + metrics.widthPixels + ", " + metrics.heightPixels + "]."; + throw new IllegalArgumentException(error); } }