Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4989618

Browse files
blerouxharryterkelsen
authored andcommitted
[Android] Rename allowChannelBufferOverflow to `setWarnsOnChannelOv… (#46361)
## Description This PR is a follow-up to #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/93e8901490e78c7ba7e319cce4470d9c6478c6dc/lib/ui/channel_buffers.dart#L574 During the review of the iOS/macOS implementation, #44848 (comment), 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 flutter/flutter#132386. ## Tests Updates 1 test.
1 parent b46e906 commit 4989618

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ public void resizeChannelBuffer(int newSize) {
144144

145145
/**
146146
* Toggles whether the channel should show warning messages when discarding messages due to
147-
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
147+
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
148148
* not be shown.
149149
*/
150-
public void allowChannelBufferOverflow(boolean allowed) {
151-
allowChannelBufferOverflow(messenger, name, allowed);
150+
public void setWarnsOnChannelOverflow(boolean warns) {
151+
setWarnsOnChannelOverflow(messenger, name, warns);
152152
}
153153

154154
private static ByteBuffer packetFromEncodedMessage(ByteBuffer message) {
@@ -182,13 +182,13 @@ public static void resizeChannelBuffer(
182182

183183
/**
184184
* Toggles whether the channel should show warning messages when discarding messages due to
185-
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
185+
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
186186
* not be shown.
187187
*/
188-
public static void allowChannelBufferOverflow(
189-
@NonNull BinaryMessenger messenger, @NonNull String channel, boolean allowed) {
188+
public static void setWarnsOnChannelOverflow(
189+
@NonNull BinaryMessenger messenger, @NonNull String channel, boolean warns) {
190190
final StandardMethodCodec codec = StandardMethodCodec.INSTANCE;
191-
Object[] arguments = {channel, allowed};
191+
Object[] arguments = {channel, !warns};
192192
MethodCall methodCall = new MethodCall("overflow", Arrays.asList(arguments));
193193
ByteBuffer message = codec.encodeMethodCall(methodCall);
194194
ByteBuffer packet = packetFromEncodedMessage(message);

shell/platform/android/io/flutter/plugin/common/MethodChannel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ public void resizeChannelBuffer(int newSize) {
159159

160160
/**
161161
* Toggles whether the channel should show warning messages when discarding messages due to
162-
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
162+
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
163163
* not be shown.
164164
*/
165-
public void allowChannelBufferOverflow(boolean allowed) {
166-
BasicMessageChannel.allowChannelBufferOverflow(messenger, name, allowed);
165+
public void setWarnsOnChannelOverflow(boolean warns) {
166+
BasicMessageChannel.setWarnsOnChannelOverflow(messenger, name, warns);
167167
}
168168

169169
/** A handler of incoming method calls. */

shell/platform/android/test/io/flutter/plugin/common/MethodChannelTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void overflowChannelBufferMessageIsWellformed() {
5656
String channel = "flutter/test";
5757
MethodChannel rawChannel = new MethodChannel(dartExecutor, channel);
5858

59-
rawChannel.allowChannelBufferOverflow(true);
59+
rawChannel.setWarnsOnChannelOverflow(false);
6060

6161
// Created from the following Dart code:
6262
// MethodCall methodCall = const MethodCall('overflow', ['flutter/test', true]);

0 commit comments

Comments
 (0)