diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java index 489ef7ecec..9a99de87bf 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -208,10 +208,8 @@ public class StandardMessageCodec implements MessageCodec { protected void writeValue(ByteArrayOutputStream stream, Object value) { if (value == null || value.equals(null)) { stream.write(NULL); - } else if (value == Boolean.TRUE) { - stream.write(TRUE); - } else if (value == Boolean.FALSE) { - stream.write(FALSE); + } else if (value instanceof Boolean) { + stream.write(((Boolean) value).booleanValue() ? TRUE : FALSE); } else if (value instanceof Number) { if (value instanceof Integer || value instanceof Short || value instanceof Byte) { stream.write(INT); diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java index 0d5922cbbd..5a3223d59f 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/common/StandardMessageCodecTest.java @@ -75,4 +75,22 @@ public class StandardMessageCodecTest { expected.flip(); assertEquals(expected, message); } + + @Test + @SuppressWarnings("deprecation") + public void itEncodesBooleans() { + // Setup message codec + StandardMessageCodec codec = new StandardMessageCodec(); + + ArrayList messageContent = new ArrayList(); + // Test handling of Boolean objects other than the static TRUE and FALSE constants. + messageContent.add(new Boolean(true)); + messageContent.add(new Boolean(false)); + ByteBuffer message = codec.encodeMessage(messageContent); + message.flip(); + ByteBuffer expected = ByteBuffer.allocateDirect(4); + expected.put(new byte[] {LIST, 2, TRUE, FALSE}); + expected.flip(); + assertEquals(expected, message); + } } diff --git a/engine/src/flutter/tools/android_lint/baseline.xml b/engine/src/flutter/tools/android_lint/baseline.xml index 2e8237cffb..39bdc950e5 100644 --- a/engine/src/flutter/tools/android_lint/baseline.xml +++ b/engine/src/flutter/tools/android_lint/baseline.xml @@ -166,4 +166,26 @@ column="20"/> + + + + + + + +