Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17f7b518 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Gerrit Code Review
Browse files

Merge "Limit max packet length for cover art"

parents 1d25583c a45661dc
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class BluetoothObexTransport implements ObexTransport {
    private int mMaxTransmitPacketSize = PACKET_SIZE_UNSPECIFIED;
    private int mMaxReceivePacketSize = PACKET_SIZE_UNSPECIFIED;

    private boolean mIsCoverArt = false;

    public BluetoothObexTransport(BluetoothSocket socket) {
        this.mSocket = socket;
    }
@@ -97,7 +99,9 @@ public class BluetoothObexTransport implements ObexTransport {

    @Override
    public int getMaxTransmitPacketSize() {
        if (mSocket.getConnectionType() != BluetoothSocket.TYPE_L2CAP) {
        if (mSocket.getConnectionType() != BluetoothSocket.TYPE_L2CAP
            || (mIsCoverArt
                && mMaxTransmitPacketSize != PACKET_SIZE_UNSPECIFIED)) {
            return mMaxTransmitPacketSize;
        }
        return mSocket.getMaxTransmitPacketSize();
@@ -125,4 +129,8 @@ public class BluetoothObexTransport implements ObexTransport {
        }
        return false;
    }

    public void setConnectionForCoverArt(boolean isCoverArt) {
        mIsCoverArt = isCoverArt;
    }
}
+12 −3
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@ import javax.obex.ServerSession;
/**
 * The AVRCP Cover Art Service
 *
 * This service handles allocation of image handles and storage of images. It also owns the BIP OBEX
 * server that handles requests to get AVRCP cover artwork.
 * This service handles allocation of image handles and storage of images. It also owns the
 * BIP OBEX server that handles requests to get AVRCP cover artwork.
 */
public class AvrcpCoverArtService {
    private static final String TAG = "AvrcpCoverArtService";
@@ -44,6 +44,12 @@ public class AvrcpCoverArtService {

    private static final int COVER_ART_STORAGE_MAX_ITEMS = 32;

    /**
     * Limiting transmit packet size because some carkits are disconnected if
     * AVRCP Cover Art OBEX packet size exceed 1024 bytes.
     */
    private static final int MAX_TRANSMIT_PACKET_SIZE = 1024;

    private final Context mContext;

    // Cover Art and Image Handle objects
@@ -207,7 +213,10 @@ public class AvrcpCoverArtService {
                    disconnect(device);
                }
            });
            BluetoothObexTransport transport = new BluetoothObexTransport(socket);
            BluetoothObexTransport transport = new BluetoothObexTransport(socket,
                    MAX_TRANSMIT_PACKET_SIZE,
                    BluetoothObexTransport.PACKET_SIZE_UNSPECIFIED);
            transport.setConnectionForCoverArt(true);
            try {
                ServerSession session = new ServerSession(transport, s, null);
                mClients.put(device, session);