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
This commit is contained in:
Kaushik Iska 2019-04-29 17:19:05 -07:00 committed by GitHub
parent ee3f04ac80
commit 5aa5b6cbf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
}