what-the-bank/sources/io/flutter/plugin/common/BinaryCodec.java

35 lines
1.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.flutter.plugin.common;
import java.nio.ByteBuffer;
/* loaded from: classes6.dex */
public final class BinaryCodec implements MessageCodec<ByteBuffer> {
public static final BinaryCodec INSTANCE = new BinaryCodec();
public static final BinaryCodec INSTANCE_DIRECT = new BinaryCodec(true);
private final boolean returnsDirectByteBufferFromDecoding;
@Override // io.flutter.plugin.common.MessageCodec
public final ByteBuffer encodeMessage(ByteBuffer byteBuffer) {
return byteBuffer;
}
private BinaryCodec() {
this.returnsDirectByteBufferFromDecoding = false;
}
private BinaryCodec(boolean z) {
this.returnsDirectByteBufferFromDecoding = z;
}
@Override // io.flutter.plugin.common.MessageCodec
public final ByteBuffer decodeMessage(ByteBuffer byteBuffer) {
if (byteBuffer == null || this.returnsDirectByteBufferFromDecoding) {
return byteBuffer;
}
ByteBuffer allocate = ByteBuffer.allocate(byteBuffer.capacity());
allocate.put(byteBuffer);
allocate.rewind();
return allocate;
}
}