summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothOutputStream.java
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2009-09-02 11:51:35 -0700
committerNick Pelly <npelly@google.com>2009-09-02 11:51:35 -0700
commit4cd2cd92746e80798c79161791a4042251ed356a (patch)
tree893dbbf737d4ffd2064d651f80ac33cd9ae4b702 /framework/java/android/bluetooth/BluetoothOutputStream.java
parent0d5387689d2eda5a4002fa228b8c11e931e9de5f (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/BluetoothOutputStream.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothOutputStream.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/framework/java/android/bluetooth/BluetoothOutputStream.java b/framework/java/android/bluetooth/BluetoothOutputStream.java
index 7e2ead478a..62242a2672 100644
--- a/framework/java/android/bluetooth/BluetoothOutputStream.java
+++ b/framework/java/android/bluetooth/BluetoothOutputStream.java
@@ -53,7 +53,7 @@ import java.io.OutputStream;
public void write(int oneByte) throws IOException {
byte b[] = new byte[1];
b[0] = (byte)oneByte;
- mSocket.writeNative(b, 0, 1);
+ mSocket.write(b, 0, 1);
}
/**
@@ -82,6 +82,6 @@ import java.io.OutputStream;
if ((offset | count) < 0 || count > b.length - offset) {
throw new IndexOutOfBoundsException("invalid offset or length");
}
- mSocket.writeNative(b, offset, count);
+ mSocket.write(b, offset, count);
}
}