diff options
author | Nick Pelly <npelly@google.com> | 2009-09-02 11:51:35 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-09-02 11:51:35 -0700 |
commit | 4cd2cd92746e80798c79161791a4042251ed356a (patch) | |
tree | 893dbbf737d4ffd2064d651f80ac33cd9ae4b702 /framework/java/android/bluetooth/BluetoothInputStream.java | |
parent | 0d5387689d2eda5a4002fa228b8c11e931e9de5f (diff) |
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.
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothInputStream.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothInputStream.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/framework/java/android/bluetooth/BluetoothInputStream.java b/framework/java/android/bluetooth/BluetoothInputStream.java index c060f3263e..03af95337c 100644 --- a/framework/java/android/bluetooth/BluetoothInputStream.java +++ b/framework/java/android/bluetooth/BluetoothInputStream.java @@ -37,7 +37,7 @@ import java.io.InputStream; * Return number of bytes available before this stream will block. */ public int available() throws IOException { - return mSocket.availableNative(); + return mSocket.available(); } public void close() throws IOException { @@ -57,7 +57,7 @@ import java.io.InputStream; */ public int read() throws IOException { byte b[] = new byte[1]; - int ret = mSocket.readNative(b, 0, 1); + int ret = mSocket.read(b, 0, 1); if (ret == 1) { return (int)b[0] & 0xff; } else { @@ -93,6 +93,6 @@ import java.io.InputStream; if ((offset | length) < 0 || length > b.length - offset) { throw new ArrayIndexOutOfBoundsException("invalid offset or length"); } - return mSocket.readNative(b, offset, length); + return mSocket.read(b, offset, length); } } |