FileDocCategorySizeDatePackage
BluetoothMnsObexServer.javaAPI DocAndroid 5.1 API4064Thu Mar 12 22:22:50 GMT 2015android.bluetooth.client.map

BluetoothMnsObexServer

public class BluetoothMnsObexServer extends javax.obex.ServerRequestHandler

Fields Summary
private static final String
TAG
private static final byte[]
MNS_TARGET
private static final String
TYPE
private final android.os.Handler
mCallback
Constructors Summary
public BluetoothMnsObexServer(android.os.Handler callback)


       
        super();

        mCallback = callback;
    
Methods Summary
public intonAbort(javax.obex.HeaderSet request, javax.obex.HeaderSet reply)

        Log.v(TAG, "onAbort");

        return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
    
public voidonClose()

        Log.v(TAG, "onClose");

        // TODO: call session handler so it can disconnect
    
public intonConnect(javax.obex.HeaderSet request, javax.obex.HeaderSet reply)

        Log.v(TAG, "onConnect");

        try {
            byte[] uuid = (byte[]) request.getHeader(HeaderSet.TARGET);

            if (!Arrays.equals(uuid, MNS_TARGET)) {
                return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
            }

        } catch (IOException e) {
            // this should never happen since getHeader won't throw exception it
            // declares to throw
            return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
        }

        reply.setHeader(HeaderSet.WHO, MNS_TARGET);
        return ResponseCodes.OBEX_HTTP_OK;
    
public voidonDisconnect(javax.obex.HeaderSet request, javax.obex.HeaderSet reply)

        Log.v(TAG, "onDisconnect");
    
public intonGet(javax.obex.Operation op)

        Log.v(TAG, "onGet");

        return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
    
public intonPut(javax.obex.Operation op)

        Log.v(TAG, "onPut");

        try {
            HeaderSet headerset;
            headerset = op.getReceivedHeader();

            String type = (String) headerset.getHeader(HeaderSet.TYPE);
            ObexAppParameters oap = ObexAppParameters.fromHeaderSet(headerset);

            if (!TYPE.equals(type) || !oap.exists(BluetoothMasRequest.OAP_TAGID_MAS_INSTANCE_ID)) {
                return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
            }

            Byte inst = oap.getByte(BluetoothMasRequest.OAP_TAGID_MAS_INSTANCE_ID);

            BluetoothMapEventReport ev = BluetoothMapEventReport.fromStream(op
                    .openDataInputStream());

            op.close();

            mCallback.obtainMessage(BluetoothMnsService.MSG_EVENT, inst, 0, ev).sendToTarget();
        } catch (IOException e) {
            Log.e(TAG, "I/O exception when handling PUT request", e);
            return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
        }

        return ResponseCodes.OBEX_HTTP_OK;
    
public intonSetPath(javax.obex.HeaderSet request, javax.obex.HeaderSet reply, boolean backup, boolean create)

        Log.v(TAG, "onSetPath");

        return ResponseCodes.OBEX_HTTP_BAD_REQUEST;