summaryrefslogtreecommitdiffstats
path: root/core/jni
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
commit71c3c7806acb2b2b7b8441817c26a2101d447bbe (patch)
tree615e8145d3d6506dc1bdeafa61f6b00675579eaf /core/jni
parent05a6f3cde52e5fbbad5187615bfc87d58559161f (diff)
downloadframeworks_base-71c3c7806acb2b2b7b8441817c26a2101d447bbe.zip
frameworks_base-71c3c7806acb2b2b7b8441817c26a2101d447bbe.tar.gz
frameworks_base-71c3c7806acb2b2b7b8441817c26a2101d447bbe.tar.bz2
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 'core/jni')
-rw-r--r--core/jni/android_bluetooth_BluetoothSocket.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp
index 0aeaadc..51cf0cb 100644
--- a/core/jni/android_bluetooth_BluetoothSocket.cpp
+++ b/core/jni/android_bluetooth_BluetoothSocket.cpp
@@ -468,7 +468,7 @@ static jint writeNative(JNIEnv *env, jobject obj, jbyteArray jb, jint offset,
return -1;
}
-static void closeNative(JNIEnv *env, jobject obj) {
+static void abortNative(JNIEnv *env, jobject obj) {
#ifdef HAVE_BLUETOOTH
LOGV(__FUNCTION__);
struct asocket *s = get_socketData(env, obj);
@@ -510,7 +510,7 @@ static JNINativeMethod sMethods[] = {
{"availableNative", "()I", (void *) availableNative},
{"readNative", "([BII)I", (void *) readNative},
{"writeNative", "([BII)I", (void *) writeNative},
- {"closeNative", "()V", (void *) closeNative},
+ {"abortNative", "()V", (void *) abortNative},
{"destroyNative", "()V", (void *) destroyNative},
};