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.
diff --git a/core/java/android/bluetooth/BluetoothInputStream.java b/core/java/android/bluetooth/BluetoothInputStream.java
index c060f32..03af953 100644
--- a/core/java/android/bluetooth/BluetoothInputStream.java
+++ b/core/java/android/bluetooth/BluetoothInputStream.java
@@ -37,7 +37,7 @@
      * 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 @@
      */
     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 @@
         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);
     }
 }