From 9e3e33e3e4fca44c5633cc9675c2833d05698332 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 7 May 2019 23:19:29 -0700 Subject: [PATCH 1/3] more logs --- .../io/flutter/plugin/common/BasicMessageChannel.java | 6 +++--- .../android/io/flutter/plugin/common/EventChannel.java | 6 +++--- .../android/io/flutter/plugin/common/FlutterException.java | 4 +++- .../android/io/flutter/plugin/common/MethodChannel.java | 6 +++--- .../io/flutter/plugin/common/StandardMessageCodec.java | 3 ++- .../platform/android/io/flutter/view/ResourceExtractor.java | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java b/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java index 35200a22ed1c5..ae21e897363ec 100644 --- a/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java +++ b/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java @@ -42,13 +42,13 @@ public final class BasicMessageChannel { public BasicMessageChannel(BinaryMessenger messenger, String name, MessageCodec 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; diff --git a/shell/platform/android/io/flutter/plugin/common/EventChannel.java b/shell/platform/android/io/flutter/plugin/common/EventChannel.java index 72fd371296cd0..2866691275fa4 100644 --- a/shell/platform/android/io/flutter/plugin/common/EventChannel.java +++ b/shell/platform/android/io/flutter/plugin/common/EventChannel.java @@ -59,13 +59,13 @@ public EventChannel(BinaryMessenger messenger, String name) { 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; diff --git a/shell/platform/android/io/flutter/plugin/common/FlutterException.java b/shell/platform/android/io/flutter/plugin/common/FlutterException.java index 5b643c7561e21..a527fccbdc152 100644 --- a/shell/platform/android/io/flutter/plugin/common/FlutterException.java +++ b/shell/platform/android/io/flutter/plugin/common/FlutterException.java @@ -10,13 +10,15 @@ * 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; diff --git a/shell/platform/android/io/flutter/plugin/common/MethodChannel.java b/shell/platform/android/io/flutter/plugin/common/MethodChannel.java index 9ffcdaa2074a7..1c8c8636faf44 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodChannel.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodChannel.java @@ -58,13 +58,13 @@ public MethodChannel(BinaryMessenger messenger, String name) { 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; diff --git a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java index dfe11e86c49ae..9d5def7bb189c 100644 --- a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -60,6 +60,7 @@ *

To extend the codec, overwrite the writeValue and readValueOfType methods.

*/ public class StandardMessageCodec implements MessageCodec { + private static final String TAG = "StandardMessageCodec#"; public static final StandardMessageCodec INSTANCE = new StandardMessageCodec(); @Override @@ -110,7 +111,7 @@ public Object decodeMessage(ByteBuffer message) { */ 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); diff --git a/shell/platform/android/io/flutter/view/ResourceExtractor.java b/shell/platform/android/io/flutter/view/ResourceExtractor.java index a25e5b43ae98f..bbdcbf9e8786d 100644 --- a/shell/platform/android/io/flutter/view/ResourceExtractor.java +++ b/shell/platform/android/io/flutter/view/ResourceExtractor.java @@ -172,7 +172,7 @@ ResourceExtractor addResources(@NonNull Collection resources) { 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); From ca48f0698049a52bd572eb1a4c320fc1df78aaa5 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 7 May 2019 23:42:25 -0700 Subject: [PATCH 2/3] fix logs in a11y bridge and update imports --- .../android/io/flutter/plugin/common/FlutterException.java | 2 ++ .../io/flutter/plugin/common/StandardMessageCodec.java | 2 ++ .../platform/android/io/flutter/view/AccessibilityBridge.java | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/common/FlutterException.java b/shell/platform/android/io/flutter/plugin/common/FlutterException.java index a527fccbdc152..6d116464520a2 100644 --- a/shell/platform/android/io/flutter/plugin/common/FlutterException.java +++ b/shell/platform/android/io/flutter/plugin/common/FlutterException.java @@ -4,6 +4,8 @@ package io.flutter.plugin.common; +import android.util.Log; + import io.flutter.BuildConfig; /** diff --git a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java index 9d5def7bb189c..20c4f392ea5de 100644 --- a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -4,6 +4,8 @@ package io.flutter.plugin.common; +import android.util.Log; + import io.flutter.BuildConfig; import java.io.ByteArrayOutputStream; diff --git a/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/shell/platform/android/io/flutter/view/AccessibilityBridge.java index b2e3a5b47aa16..e3641c47a70c0 100644 --- a/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -1330,7 +1330,9 @@ void updateSemantics(@NonNull ByteBuffer buffer, @NonNull String[] strings) { 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)) { + if (object.childrenInHitTestOrder.size() <= object.scrollIndex) { + Log.e(TAG, String.format("Got a scroll index %d, but only %d children in hit test order.", object.scrollIndex, object.childrenInHitTestOrder.size())); + } else if (object.childrenInHitTestOrder.get(object.scrollIndex).hasFlag(Flag.IS_HIDDEN)) { Log.e(TAG, "Attempted to move Accessibility Focus to hidden child."); } } From 2e47c57907c2e89100132a793f3eda7925992ba8 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 8 May 2019 00:59:46 -0700 Subject: [PATCH 3/3] remove bogus logs --- .../android/io/flutter/view/AccessibilityBridge.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/shell/platform/android/io/flutter/view/AccessibilityBridge.java index e3641c47a70c0..1d295404862cd 100644 --- a/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -1330,11 +1330,6 @@ void updateSemantics(@NonNull ByteBuffer buffer, @NonNull String[] strings) { if (object.scrollIndex + visibleChildren > object.scrollChildren) { Log.e(TAG, "Scroll index is out of bounds."); } - if (object.childrenInHitTestOrder.size() <= object.scrollIndex) { - Log.e(TAG, String.format("Got a scroll index %d, but only %d children in hit test order.", object.scrollIndex, object.childrenInHitTestOrder.size())); - } else 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.