未验证 提交 5d1c1a02 编写于 作者: D Dan Field 提交者: GitHub

Remove more asserts and fix a11y check (#8896)

上级 ac4f3c99
......@@ -42,13 +42,13 @@ public final class BasicMessageChannel<T> {
public BasicMessageChannel(BinaryMessenger messenger, String name, MessageCodec<T> codec) {
if (BuildConfig.DEBUG) {
if (messenger == null) {
throw new AssertionError("Parameter messenger must not be null.");
Log.e(TAG, "Parameter messenger must not be null.");
}
if (name == null) {
throw new AssertionError("Parameter name must not be null.");
Log.e(TAG, "Parameter name must not be null.");
}
if (codec == null) {
throw new AssertionError("Parameter codec must not be null.");
Log.e(TAG, "Parameter codec must not be null.");
}
}
this.messenger = messenger;
......
......@@ -59,13 +59,13 @@ public final class EventChannel {
public EventChannel(BinaryMessenger messenger, String name, MethodCodec codec) {
if (BuildConfig.DEBUG) {
if (messenger == null) {
throw new AssertionError("Parameter messenger must not be null.");
Log.e(TAG, "Parameter messenger must not be null.");
}
if (name == null) {
throw new AssertionError("Parameter name must not be null.");
Log.e(TAG, "Parameter name must not be null.");
}
if (codec == null) {
throw new AssertionError("Parameter codec must not be null.");
Log.e(TAG, "Parameter codec must not be null.");
}
}
this.messenger = messenger;
......
......@@ -4,19 +4,23 @@
package io.flutter.plugin.common;
import android.util.Log;
import io.flutter.BuildConfig;
/**
* Thrown to indicate that a Flutter method invocation failed on the Flutter side.
*/
public class FlutterException extends RuntimeException {
private static final String TAG = "FlutterException#";
public final String code;
public final Object details;
FlutterException(String code, String message, Object details) {
super(message);
if (BuildConfig.DEBUG && code == null) {
throw new AssertionError("Parameter code must not be null.");
Log.e(TAG, "Parameter code must not be null.");
}
this.code = code;
this.details = details;
......
......@@ -58,13 +58,13 @@ public final class MethodChannel {
public MethodChannel(BinaryMessenger messenger, String name, MethodCodec codec) {
if (BuildConfig.DEBUG) {
if (messenger == null) {
throw new AssertionError("Parameter messenger must not be null.");
Log.e(TAG, "Parameter messenger must not be null.");
}
if (name == null) {
throw new AssertionError("Parameter name must not be null.");
Log.e(TAG, "Parameter name must not be null.");
}
if (codec == null) {
throw new AssertionError("Parameter codec must not be null.");
Log.e(TAG, "Parameter codec must not be null.");
}
}
this.messenger = messenger;
......
......@@ -4,6 +4,8 @@
package io.flutter.plugin.common;
import android.util.Log;
import io.flutter.BuildConfig;
import java.io.ByteArrayOutputStream;
......@@ -60,6 +62,7 @@ import java.util.Map.Entry;
* <p>To extend the codec, overwrite the writeValue and readValueOfType methods.</p>
*/
public class StandardMessageCodec implements MessageCodec<Object> {
private static final String TAG = "StandardMessageCodec#";
public static final StandardMessageCodec INSTANCE = new StandardMessageCodec();
@Override
......@@ -110,7 +113,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
*/
protected static final void writeSize(ByteArrayOutputStream stream, int value) {
if (BuildConfig.DEBUG && 0 > value) {
throw new AssertionError("Attempted to write a negative size.");
Log.e(TAG, "Attempted to write a negative size.");
}
if (value < 254) {
stream.write(value);
......
......@@ -1330,9 +1330,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
if (object.scrollIndex + visibleChildren > object.scrollChildren) {
Log.e(TAG, "Scroll index is out of bounds.");
}
if (object.childrenInHitTestOrder.get(object.scrollIndex).hasFlag(Flag.IS_HIDDEN)) {
Log.e(TAG, "Attempted to move Accessibility Focus to hidden child.");
}
}
// The setToIndex should be the index of the last visible child. Because we counted all
// children, including the first index we need to subtract one.
......
......@@ -172,7 +172,7 @@ class ResourceExtractor {
ResourceExtractor start() {
if (BuildConfig.DEBUG && mExtractTask != null) {
throw new AssertionError("Attempted to start resource extraction while another extraction was in progress.");
Log.e(TAG, "Attempted to start resource extraction while another extraction was in progress.");
}
mExtractTask = new ExtractTask(mDataDirPath, mResources, mPackageName, mPackageManager, mAssetManager);
mExtractTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册