private void startDecode(SSLEngine engine, ByteBuffer input, CodecCallback callback)
            throws IOException {
        if (mEngineClosed) {
            return;
        }
        if (mHandshakeFinished) {
            boolean isRenegotiation = input.get(input.position()) ==
                    SSLUtils.SSL_CONTENT_TYPE_HANDSHAKE;
            unwrap(engine, input, callback);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
                // Fixed a SSL renegotiation issue for API 27+
                // However below API 27, system SSLEngine doesn't support renegotiation.
                if (isRenegotiation) {
                    handshakeWrap(engine, callback);
                }
            }
        } else {
            handshake(engine, input, callback);
        }
        // Start wrap plaintext to engine if possible.
        if (mHandshakeFinished && !mPlaintextBuffers.isEmpty()) {
            ByteBuffer plaintextBuffer;
            while (!mPlaintextBuffers.isEmpty()) {
                plaintextBuffer = mPlaintextBuffers.poll();
                if (plaintextBuffer != null && plaintextBuffer.hasRemaining()) {
                    wrap(engine, plaintextBuffer, callback);
                }
            }
        }
    }
Try to encrypt a plaintext packet. If SSL handshake has finished, then encode it,
otherwise add it to queue and wait handshake finished.

@param buffer The plaintext packet.
@param callback A callback to observe actions and receive output packets.
@throws IOException If an I/O error has occurred.
netbare-core/src/main/java/com/github/megatronking/netbare/ssl/SSLCodec.java