Skip to content

Commit

Permalink
Ported: Bluetooth Message Access Profile (MAP) from CM9
Browse files Browse the repository at this point in the history
This was added to CM10 to restore message exchange capabilities with automotive systems.

Change-Id: Ib872bebc5c292b1f84c903b068e59b7eeca6d76f
  • Loading branch information
cgarst authored and rmcc committed Nov 21, 2012
1 parent d39a1f8 commit 0e5fdcf
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
14 changes: 13 additions & 1 deletion core/java/android/bluetooth/BluetoothUuid.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public final class BluetoothUuid {
ParcelUuid.fromString("00001105-0000-1000-8000-00805f9b34fb"); ParcelUuid.fromString("00001105-0000-1000-8000-00805f9b34fb");
public static final ParcelUuid Hid = public static final ParcelUuid Hid =
ParcelUuid.fromString("00001124-0000-1000-8000-00805f9b34fb"); ParcelUuid.fromString("00001124-0000-1000-8000-00805f9b34fb");
public static final ParcelUuid MessageAccessServer =
ParcelUuid.fromString("00001132-0000-1000-8000-00805f9b34fb");
public static final ParcelUuid MessageNotificationServer =
ParcelUuid.fromString("00001133-0000-1000-8000-00805f9b34fb");
public static final ParcelUuid PANU = public static final ParcelUuid PANU =
ParcelUuid.fromString("00001115-0000-1000-8000-00805F9B34FB"); ParcelUuid.fromString("00001115-0000-1000-8000-00805F9B34FB");
public static final ParcelUuid NAP = public static final ParcelUuid NAP =
Expand All @@ -67,7 +71,7 @@ public final class BluetoothUuid {


public static final ParcelUuid[] RESERVED_UUIDS = { public static final ParcelUuid[] RESERVED_UUIDS = {
AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget, AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget,
ObexObjectPush, PANU, NAP}; ObexObjectPush, MessageAccessServer, MessageNotificationServer, PANU, NAP};


public static boolean isAudioSource(ParcelUuid uuid) { public static boolean isAudioSource(ParcelUuid uuid) {
return uuid.equals(AudioSource); return uuid.equals(AudioSource);
Expand Down Expand Up @@ -131,6 +135,14 @@ public static boolean isUuidPresent(ParcelUuid[] uuidArray, ParcelUuid uuid) {
return false; return false;
} }


public static boolean isMessageAccessServer(ParcelUuid uuid) {
return uuid.equals(MessageAccessServer);
}

public static boolean isMessageNotificationServer(ParcelUuid uuid) {
return uuid.equals(MessageNotificationServer);
}

/** /**
* Returns true if there any common ParcelUuids in uuidA and uuidB. * Returns true if there any common ParcelUuids in uuidA and uuidB.
* *
Expand Down
12 changes: 11 additions & 1 deletion obex/javax/obex/ClientOperation.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008-2009, Motorola, Inc. * Copyright (c) 2010-2011, Motorola, Inc.
* *
* All rights reserved. * All rights reserved.
* *
Expand Down Expand Up @@ -121,6 +121,12 @@ public ClientOperation(int maxSize, ClientSession p, HeaderSet header, boolean t
(header).mAuthResp.length); (header).mAuthResp.length);


} }
if ((header).mConnectionID != null) {
mRequestHeader.mConnectionID = new byte[4];
System.arraycopy((header).mConnectionID, 0, mRequestHeader.mConnectionID, 0,
4);

}
} }


/** /**
Expand Down Expand Up @@ -723,4 +729,8 @@ public void streamClosed(boolean inStream) throws IOException {
} }
} }
} }

public void noEndofBody() {

}
} }
2 changes: 2 additions & 0 deletions obex/javax/obex/Operation.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public interface Operation {


DataOutputStream openDataOutputStream() throws IOException; DataOutputStream openDataOutputStream() throws IOException;


void noEndofBody();

void close() throws IOException; void close() throws IOException;


int getMaxPacketSize(); int getMaxPacketSize();
Expand Down
36 changes: 25 additions & 11 deletions obex/javax/obex/ServerOperation.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008-2009, Motorola, Inc. * Copyright (c) 2010-2011, Motorola, Inc.
* *
* All rights reserved. * All rights reserved.
* *
Expand Down Expand Up @@ -88,6 +88,8 @@ public final class ServerOperation implements Operation, BaseStream {


private boolean mHasBody; private boolean mHasBody;


private boolean mEndofBody = true;

/** /**
* Creates new ServerOperation * Creates new ServerOperation
* @param p the parent that created this object * @param p the parent that created this object
Expand Down Expand Up @@ -364,24 +366,31 @@ public synchronized boolean sendReply(int type) throws IOException {
* (End of Body) otherwise, we need to send 0x48 (Body) * (End of Body) otherwise, we need to send 0x48 (Body)
*/ */
if ((finalBitSet) || (mPrivateOutput.isClosed())) { if ((finalBitSet) || (mPrivateOutput.isClosed())) {
out.write(0x49); if (mEndofBody) {
out.write((byte)0x49);
bodyLength += 3;
out.write((byte)(bodyLength >> 8));
out.write((byte)bodyLength);
out.write(body);
}
} else { } else {
out.write(0x48); out.write(0x48);
bodyLength += 3;
out.write((byte)(bodyLength >> 8));
out.write((byte)bodyLength);
out.write(body);
} }


bodyLength += 3;
out.write((byte)(bodyLength >> 8));
out.write((byte)bodyLength);
out.write(body);
} }
} }


if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) { if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) {
out.write(0x49); if (mEndofBody) {
orginalBodyLength = 3; out.write(0x49);
out.write((byte)(orginalBodyLength >> 8)); orginalBodyLength = 3;
out.write((byte)orginalBodyLength); out.write((byte)(orginalBodyLength >> 8));

out.write((byte)orginalBodyLength);
}
} }


mResponseSize = 3; mResponseSize = 3;
Expand Down Expand Up @@ -711,4 +720,9 @@ public void ensureNotDone() throws IOException {
public void streamClosed(boolean inStream) throws IOException { public void streamClosed(boolean inStream) throws IOException {


} }

public void noEndofBody() {
mEndofBody = false;
}

} }

0 comments on commit 0e5fdcf

Please sign in to comment.