summaryrefslogtreecommitdiffstats
path: root/core/jni/android_bluetooth_BluetoothSocket.cpp
Commit message (Collapse)AuthorAgeFilesLines
* am 27e00544: am 9907d161: Merge "Fix data corruption when writing to ↵Brad Fitzpatrick2011-04-041-7/+13
|\ | | | | | | | | | | | | Bluetooth socket" * commit '27e00544ea08d25e8e9b1b94264205f9d53030fb': Fix data corruption when writing to Bluetooth socket
| * Fix data corruption when writing to Bluetooth socketMike Playle2011-04-041-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix compiler errors when compiled with debug option.Jaikumar Ganesh2011-02-221-10/+10
|/ | | | | | The Logv statement was missing the format specifier. Change-Id: Ibf986d28dabfdbb3fbfd75381cb349448c6e57e7
* Provide an API for apps to use a dynamic RFCOMM channel and SDP record.Nick Pelly2009-10-061-11/+14
| | | | | | | | | | | | | | | | | | | | | | 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
* Bounds check read and write path in native code.Nick Pelly2009-09-251-2/+20
| | | | | | Already checked in Java, but requested by security review. Change-Id: I5314dbc32546278b977236a154fba03f38610b1a
* Use LM_SECURE when auth && encrypt.Nick Pelly2009-09-241-2/+4
| | | | | | LM_SECURE enforces man in the middle (MITM) protection. Change-Id: Ia800bb657b429f8872d72072f7c9450a74028af0
* Immediately destroy BluetoothSocket's on close().Nick Pelly2009-09-021-2/+2
| | | | | | | | | | | | | | | 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.
* Set RFCOMM SO_SNDBUF size to 70 KB for large RFCOMM writes.Nick Pelly2009-08-311-1/+18
| | | | | | | | 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.
* Implement and expose SCO socket support in BluetoothSocket.java.Nick Pelly2009-06-021-27/+192
| | | | | | Implement L2CAP socket support, but do not expose it (untested). NEXT: Switch to Builder style constructor instead of factory method.
* Implement bulk read and writes for Bluetooth sockets.Nick Pelly2009-06-021-11/+39
| | | | | | Before: 0.1 kB/s After: 100 kB/s (in my java BT speed test app)
* Fix the boot. The signature needed a V at the end.Patrick Scott2009-05-271-1/+1
|
* New BluetoothSocket API.Nick Pelly2009-05-261-0/+324
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; }