History log of /frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
fbbea2e1bf85bbee28fe86d1cf912929a8d09f6f 29-Jul-2011 Nick Pelly <npelly@google.com> Workaround for bug 5082381 (EALREADY on ACL collision).

If connect() fails with EALREADY, then retry.

Unfortunately we also need to switch to a new FD. This is currently
safe, but its a little fragile to changes in the code (especially
if we ever expose the fd to applications) so it would be great to
fix this issue properly in the kernel sometime and revert this
commit.

Change-Id: I12fb6b7f2b8ca40f425f66b504754048c9460329
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
75d086e5b2ed3c7ff70f60ca1f616138b825f551 17-Jul-2011 Doug Kwan <dougkwan@google.com> Add C code to use BDADDR_ANY macro properly. The macro expands into code
that is not valid C++. So we need to use a C helper.

Change-Id: I5e7a46dd2af404972c1b4b97d21398d77c339cac
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
5851b8662dc95372d68df293cb13c59da0cf8582 05-Apr-2011 Brad Fitzpatrick <bradfitz@android.com> am 27e00544: am 9907d161: Merge "Fix data corruption when writing to Bluetooth socket"

* commit '27e00544ea08d25e8e9b1b94264205f9d53030fb':
Fix data corruption when writing to Bluetooth socket
36aa8839d5509d12323a6025329d6913cbaa353b 22-Oct-2010 Mike Playle <mike.playle@realvnc.com> Fix data corruption when writing to Bluetooth socket

Writes to Bluetooth sockets are handled by writeNative() in
android_bluetooth_BluetoothSocket.cpp. This calls asocket_write()
which is implemented in abort_socket.c.

This latter function sleeps until poll() indicates that the socket is
writeable, then calls write() once, returning the number of bytes
written. However writeNative() just returns this byte count to the
caller; it's eventually ignored in BluetoothOutputStream.java. This
doesn't match the semantics of a Java OutputStream, which is required
to block until all bytes have been written.

This fix adds a loop to writeNative() that repeatedly calls the lower
level write function until all the data has been written (or an error
occurred in which case we should exit the loop early). With this
change it is possible to write large amounts of data to a Bluetooth
socket without experiencing data loss.

Change-Id: I0b464382817e15adec32ba0e3cb37e7d1cccc730
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
2653a1e7ca55b03f5230dffa85dfe2705757e2b7 22-Feb-2011 Jaikumar Ganesh <jaikumar@google.com> Fix compiler errors when compiled with debug option.

The Logv statement was missing the format specifier.

Change-Id: Ibf986d28dabfdbb3fbfd75381cb349448c6e57e7
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
24bb9b8af4ff691538fe9e517e8156016b0da6cd 03-Oct-2009 Nick Pelly <npelly@google.com> Provide an API for apps to use a dynamic RFCOMM channel and SDP record.

Hide listenUsingRfcommOn(int channel)
Add listenUsingRfcomm(String name, ParcelUuid uuid)

The new API automatically finds a free RFCOMM channel and registers an SDP
record with the given uuid and name. The SDP record is automatically
removed when the socket is closed, or if the application dies.

Apps are prevented from registering SDP records with the uuid of system
Bluetooth profiles, such as A2DP, HFP and OPP.

Apps are prevented from removing SDP records that they did not create. This is
tracked by pid.

TODO: Provide an API for the connecting app to look up an SDP record.

Bug: 2158900
DrNo: eastham
Joke: "What did the dog say to the tree? bark."
Change-Id: Ia92f51c34615a7270a403255ad2b8faa98c4a3f5
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
57a2292bffedaa3fb8f5cd6b0867fdd5772ad3b5 25-Sep-2009 Nick Pelly <npelly@google.com> Bounds check read and write path in native code.

Already checked in Java, but requested by security review.

Change-Id: I5314dbc32546278b977236a154fba03f38610b1a
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
1a42cfac152faa98c2e3d9e9fd6889209de195fe 25-Sep-2009 Nick Pelly <npelly@google.com> Use LM_SECURE when auth && encrypt.

LM_SECURE enforces man in the middle (MITM) protection.

Change-Id: Ia800bb657b429f8872d72072f7c9450a74028af0
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
71c3c7806acb2b2b7b8441817c26a2101d447bbe 02-Sep-2009 Nick Pelly <npelly@google.com> Immediately destroy BluetoothSocket's on close().

Unfortunatley, shutdown() on the underlying fd does not actually stop a
listening socket from listening. You need to call close() on the fd to
do this. There is no way around it.

So this means the Java BluetoothSocket code has to call destroyNative() during
BluetoothSocket.close().

Since native methods cannot be called after destroyNative(), add a ReadWrite
lock and mClosed field to protect access to native methods.

This fixes the "resource busy" error when Bluetooth OPP and Bluetooth PBAP
tried to resume listening after turning BT off and then on.
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
41a0a4a850184c8c936818dc0f2ac4d3ecd9a1c6 31-Aug-2009 Nick Pelly <npelly@google.com> Set RFCOMM SO_SNDBUF size to 70 KB for large RFCOMM writes.

With a 64 KB OBEX MTU, net/rfcomm/sock.c:rfcomm_sock_sendmsg() quietly drops data.

The default SO_SNDBUF is 24 KB. Empircally, 36 KB still drops, and 38 KB no longer drops (this is because SO_SNDBUF is doubled in net/core/sock.c and then there is OBEX/RFCOMM overhead). Set to 70 KB so we have plenty of room to spare.

See http://b/2090000 to investigate this in more detail later.
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
6a669fac385b51b8bb01844b77a9a43840dda854 03-Jun-2009 Nick Pelly <npelly@google.com> Implement and expose SCO socket support in BluetoothSocket.java.

Implement L2CAP socket support, but do not expose it (untested).

NEXT: Switch to Builder style constructor instead of factory method.
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
47e82dee6b18c33fab8c2cdf4f68b20d3663079e 02-Jun-2009 Nick Pelly <npelly@google.com> Implement bulk read and writes for Bluetooth sockets.

Before: 0.1 kB/s
After: 100 kB/s
(in my java BT speed test app)
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
9b36f494e52b1b0e383df5c1ae07930830f7cbbd 27-May-2009 Patrick Scott <phanna@android.com> Fix the boot. The signature needed a V at the end.
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp
0b6955a48bad9aee01ae2f0c06d3f168ca603ab7 27-May-2009 Nick Pelly <npelly@google.com> New BluetoothSocket API.

Modeled on blocking java.net.Socket and java.net.ServerSocket library.

Public interface is:

public final class BluetoothSocket implements Closeable {
public static BluetoothSocket createRfcommSocket(String address, int port) throws IOException;
public static BluetoothSocket createInsecureRfcommSocket(String address, int port) throws IOException;

public void connect() throws IOException;
public void close() throws IOException;

public String getAddress();
public InputStream getInputStream() throws IOException;
public OutputStream getOutputStream() throws IOException;
}

public final class BluetoothServerSocket implements Closeable {
public static BluetoothServerSocket listenUsingRfcommOn(int port) throws IOException;
public static BluetoothServerSocket listenUsingUnsecureRfcommOn(int port) throws IOException;

public BluetoothSocket accept() throws IOException;
public BluetoothSocket accept(int timeout) throws IOException;
public void close() throws IOException;

}
/frameworks/base/core/jni/android_bluetooth_BluetoothSocket.cpp