diff options
author | Nick Pelly <npelly@google.com> | 2009-10-02 20:34:18 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-10-06 05:57:50 -0700 |
commit | 24bb9b8af4ff691538fe9e517e8156016b0da6cd (patch) | |
tree | 18adac336dde46f3a9f1c2453a358b11689d03b9 /core/jni/android_bluetooth_BluetoothSocket.cpp | |
parent | 7fdd67d3867ecbb6457a560b2428a8e9464d8ecd (diff) | |
download | frameworks_base-24bb9b8af4ff691538fe9e517e8156016b0da6cd.zip frameworks_base-24bb9b8af4ff691538fe9e517e8156016b0da6cd.tar.gz frameworks_base-24bb9b8af4ff691538fe9e517e8156016b0da6cd.tar.bz2 |
Provide an API for apps to use a dynamic RFCOMM channel and SDP record.
Hide listenUsingRfcommOn(int channel)
Add listenUsingRfcomm(String name, ParcelUuid uuid)
The new API automatically finds a free RFCOMM channel and registers an SDP
record with the given uuid and name. The SDP record is automatically
removed when the socket is closed, or if the application dies.
Apps are prevented from registering SDP records with the uuid of system
Bluetooth profiles, such as A2DP, HFP and OPP.
Apps are prevented from removing SDP records that they did not create. This is
tracked by pid.
TODO: Provide an API for the connecting app to look up an SDP record.
Bug: 2158900
DrNo: eastham
Joke: "What did the dog say to the tree? bark."
Change-Id: Ia92f51c34615a7270a403255ad2b8faa98c4a3f5
Diffstat (limited to 'core/jni/android_bluetooth_BluetoothSocket.cpp')
-rw-r--r-- | core/jni/android_bluetooth_BluetoothSocket.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp index 2532eff..31ebf8c 100644 --- a/core/jni/android_bluetooth_BluetoothSocket.cpp +++ b/core/jni/android_bluetooth_BluetoothSocket.cpp @@ -237,7 +237,8 @@ static void connectNative(JNIEnv *env, jobject obj) { jniThrowIOException(env, ENOSYS); } -static void bindListenNative(JNIEnv *env, jobject obj) { +/* Returns errno instead of throwing, so java can check errno */ +static int bindListenNative(JNIEnv *env, jobject obj) { #ifdef HAVE_BLUETOOTH LOGV(__FUNCTION__); @@ -248,7 +249,7 @@ static void bindListenNative(JNIEnv *env, jobject obj) { struct asocket *s = get_socketData(env, obj); if (!s) - return; + return EINVAL; type = env->GetIntField(obj, field_mType); @@ -283,28 +284,25 @@ static void bindListenNative(JNIEnv *env, jobject obj) { memcpy(&addr_l2.l2_bdaddr, &bdaddr, sizeof(bdaddr_t)); break; default: - jniThrowIOException(env, ENOSYS); - return; + return ENOSYS; } if (bind(s->fd, addr, addr_sz)) { LOGV("...bind(%d) gave errno %d", s->fd, errno); - jniThrowIOException(env, errno); - return; + return errno; } if (listen(s->fd, 1)) { LOGV("...listen(%d) gave errno %d", s->fd, errno); - jniThrowIOException(env, errno); - return; + return errno; } LOGV("...bindListenNative(%d) success", s->fd); - return; + return 0; #endif - jniThrowIOException(env, ENOSYS); + return ENOSYS; } static jobject acceptNative(JNIEnv *env, jobject obj, int timeout) { @@ -521,17 +519,22 @@ static void destroyNative(JNIEnv *env, jobject obj) { jniThrowIOException(env, ENOSYS); } +static void throwErrnoNative(JNIEnv *env, jobject obj, jint err) { + jniThrowIOException(env, err); +} + static JNINativeMethod sMethods[] = { {"initSocketNative", "()V", (void*) initSocketNative}, {"initSocketFromFdNative", "(I)V", (void*) initSocketFromFdNative}, {"connectNative", "()V", (void *) connectNative}, - {"bindListenNative", "()V", (void *) bindListenNative}, + {"bindListenNative", "()I", (void *) bindListenNative}, {"acceptNative", "(I)Landroid/bluetooth/BluetoothSocket;", (void *) acceptNative}, {"availableNative", "()I", (void *) availableNative}, {"readNative", "([BII)I", (void *) readNative}, {"writeNative", "([BII)I", (void *) writeNative}, {"abortNative", "()V", (void *) abortNative}, {"destroyNative", "()V", (void *) destroyNative}, + {"throwErrnoNative", "(I)V", (void *) throwErrnoNative}, }; int register_android_bluetooth_BluetoothSocket(JNIEnv *env) { |