summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothServerSocket.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/BluetoothServerSocket.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/BluetoothServerSocket.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothServerSocket.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/framework/java/android/bluetooth/BluetoothServerSocket.java b/framework/java/android/bluetooth/BluetoothServerSocket.java
index e653c23295..b65084157e 100644
--- a/framework/java/android/bluetooth/BluetoothServerSocket.java
+++ b/framework/java/android/bluetooth/BluetoothServerSocket.java
@@ -47,6 +47,7 @@ import java.io.IOException;
* operations and close the socket.
*/
public final class BluetoothServerSocket implements Closeable {
+
/*package*/ final BluetoothSocket mSocket;
/**
@@ -88,7 +89,7 @@ public final class BluetoothServerSocket implements Closeable {
* timeout
*/
public BluetoothSocket accept(int timeout) throws IOException {
- return mSocket.acceptNative(timeout);
+ return mSocket.accept(timeout);
}
/**
@@ -97,6 +98,6 @@ public final class BluetoothServerSocket implements Closeable {
* throw an IOException.
*/
public void close() throws IOException {
- mSocket.closeNative();
+ mSocket.close();
}
}