From f732952384bb178e3283603261980df8068eb324 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Thu, 28 Sep 2023 16:08:12 +0200 Subject: [PATCH] =?UTF-8?q?[Android]=20Rename=20`allowChannelBufferOverflo?= =?UTF-8?q?w`=20to=20`setWarnsOnChannelOv=E2=80=A6=20(flutter/engine#46361?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR is a follow-up to https://github.com/flutter/engine/pull/44434 which introduces the `allowChannelBufferOverflow` function. It renames this function to `setWarnsOnChannelOverflow`. The previous naming was inspired by the framework side implementation. https://github.com/flutter/engine/blob/c00c02203662671676c5678ced4cc93f9d170df6/lib/ui/channel_buffers.dart#L574 During the review of the iOS/macOS implementation, https://github.com/flutter/engine/pull/44848#discussion_r1310463864, we agreed that the existing naming is confusing because it implies that overflow will be allowed, but this not the case this function is used to enable/disable error messages when a channel overflows. ## Related Issue Follow-up for https://github.com/flutter/flutter/issues/132386. ## Tests Updates 1 test. --- .../flutter/plugin/common/BasicMessageChannel.java | 14 +++++++------- .../io/flutter/plugin/common/MethodChannel.java | 6 +++--- .../flutter/plugin/common/MethodChannelTest.java | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java index fa21c71e95..ea6612d782 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java @@ -144,11 +144,11 @@ public final class BasicMessageChannel { /** * Toggles whether the channel should show warning messages when discarding messages due to - * overflow. When 'allowed' is true the channel is expected to overflow and warning messages will + * overflow. When 'warns' is false the channel is expected to overflow and warning messages will * not be shown. */ - public void allowChannelBufferOverflow(boolean allowed) { - allowChannelBufferOverflow(messenger, name, allowed); + public void setWarnsOnChannelOverflow(boolean warns) { + setWarnsOnChannelOverflow(messenger, name, warns); } private static ByteBuffer packetFromEncodedMessage(ByteBuffer message) { @@ -182,13 +182,13 @@ public final class BasicMessageChannel { /** * Toggles whether the channel should show warning messages when discarding messages due to - * overflow. When 'allowed' is true the channel is expected to overflow and warning messages will + * overflow. When 'warns' is false the channel is expected to overflow and warning messages will * not be shown. */ - public static void allowChannelBufferOverflow( - @NonNull BinaryMessenger messenger, @NonNull String channel, boolean allowed) { + public static void setWarnsOnChannelOverflow( + @NonNull BinaryMessenger messenger, @NonNull String channel, boolean warns) { final StandardMethodCodec codec = StandardMethodCodec.INSTANCE; - Object[] arguments = {channel, allowed}; + Object[] arguments = {channel, !warns}; MethodCall methodCall = new MethodCall("overflow", Arrays.asList(arguments)); ByteBuffer message = codec.encodeMethodCall(methodCall); ByteBuffer packet = packetFromEncodedMessage(message); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/MethodChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/MethodChannel.java index 3aa2698ad4..3191aa4e3a 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/MethodChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/MethodChannel.java @@ -159,11 +159,11 @@ public class MethodChannel { /** * Toggles whether the channel should show warning messages when discarding messages due to - * overflow. When 'allowed' is true the channel is expected to overflow and warning messages will + * overflow. When 'warns' is false the channel is expected to overflow and warning messages will * not be shown. */ - public void allowChannelBufferOverflow(boolean allowed) { - BasicMessageChannel.allowChannelBufferOverflow(messenger, name, allowed); + public void setWarnsOnChannelOverflow(boolean warns) { + BasicMessageChannel.setWarnsOnChannelOverflow(messenger, name, warns); } /** A handler of incoming method calls. */ diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/MethodChannelTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/MethodChannelTest.java index 8f8836f614..df1fa2108c 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/MethodChannelTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/MethodChannelTest.java @@ -56,7 +56,7 @@ public class MethodChannelTest { String channel = "flutter/test"; MethodChannel rawChannel = new MethodChannel(dartExecutor, channel); - rawChannel.allowChannelBufferOverflow(true); + rawChannel.setWarnsOnChannelOverflow(false); // Created from the following Dart code: // MethodCall methodCall = const MethodCall('overflow', ['flutter/test', true]);