diff options
author | Doug Kwan <dougkwan@google.com> | 2011-07-18 17:02:55 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-18 17:02:55 -0700 |
commit | 3ad4d3ce01f173e80e0ebb751c4a8913aef5648a (patch) | |
tree | 5a0352c8e00d56dac91343957fe3dccd10cb5f8c | |
parent | 9fd12cfb5667c2745df6c6fe5ae7d07a1ff5ab9e (diff) | |
parent | 75d086e5b2ed3c7ff70f60ca1f616138b825f551 (diff) | |
download | frameworks_base-3ad4d3ce01f173e80e0ebb751c4a8913aef5648a.zip frameworks_base-3ad4d3ce01f173e80e0ebb751c4a8913aef5648a.tar.gz frameworks_base-3ad4d3ce01f173e80e0ebb751c4a8913aef5648a.tar.bz2 |
Merge "Add C code to use BDADDR_ANY macro properly. The macro expands into code that is not valid C++. So we need to use a C helper."
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rwxr-xr-x | core/jni/android_bluetooth_BluetoothAudioGateway.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_bluetooth_BluetoothSocket.cpp | 3 | ||||
-rwxr-xr-x | core/jni/android_bluetooth_c.c | 31 | ||||
-rw-r--r-- | core/jni/android_bluetooth_c.h | 39 |
5 files changed, 76 insertions, 2 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 06dc083..514e59d 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -139,6 +139,7 @@ LOCAL_SRC_FILES:= \ android_bluetooth_common.cpp \ android_bluetooth_BluetoothAudioGateway.cpp \ android_bluetooth_BluetoothSocket.cpp \ + android_bluetooth_c.c \ android_server_BluetoothService.cpp \ android_server_BluetoothEventLoop.cpp \ android_server_BluetoothA2dpService.cpp \ diff --git a/core/jni/android_bluetooth_BluetoothAudioGateway.cpp b/core/jni/android_bluetooth_BluetoothAudioGateway.cpp index cb742a3..29c9c2d 100755 --- a/core/jni/android_bluetooth_BluetoothAudioGateway.cpp +++ b/core/jni/android_bluetooth_BluetoothAudioGateway.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "BluetoothAudioGateway.cpp" #include "android_bluetooth_common.h" +#include "android_bluetooth_c.h" #include "android_runtime/AndroidRuntime.h" #include "JNIHelp.h" #include "jni.h" @@ -491,7 +492,8 @@ static int setup_listening_socket(int dev, int channel) { } laddr.rc_family = AF_BLUETOOTH; - memcpy(&laddr.rc_bdaddr, BDADDR_ANY, sizeof(bdaddr_t)); + bdaddr_t any = android_bluetooth_bdaddr_any(); + memcpy(&laddr.rc_bdaddr, &any, sizeof(bdaddr_t)); laddr.rc_channel = channel; if (bind(sk, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) { diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp index d09c4e9..4c84324 100644 --- a/core/jni/android_bluetooth_BluetoothSocket.cpp +++ b/core/jni/android_bluetooth_BluetoothSocket.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "BluetoothSocket.cpp" #include "android_bluetooth_common.h" +#include "android_bluetooth_c.h" #include "android_runtime/AndroidRuntime.h" #include "JNIHelp.h" #include "utils/Log.h" @@ -245,7 +246,7 @@ static int bindListenNative(JNIEnv *env, jobject obj) { jint type; socklen_t addr_sz; struct sockaddr *addr; - bdaddr_t bdaddr = *BDADDR_ANY; + bdaddr_t bdaddr = android_bluetooth_bdaddr_any(); struct asocket *s = get_socketData(env, obj); if (!s) diff --git a/core/jni/android_bluetooth_c.c b/core/jni/android_bluetooth_c.c new file mode 100755 index 0000000..b4c6727 --- /dev/null +++ b/core/jni/android_bluetooth_c.c @@ -0,0 +1,31 @@ +/* +** Copyright 2011, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifdef HAVE_BLUETOOTH + +#include "android_bluetooth_c.h" + +/* + * A C helper for creating a bdaddr_t object with the value BDADDR_ANY. + * We have to do this in C because the macro BDADDR_ANY in bluetooth.h + * is not valid C++ code. + */ +bdaddr_t android_bluetooth_bdaddr_any(void) +{ + bdaddr_t any = *BDADDR_ANY; + return any; +} +#endif diff --git a/core/jni/android_bluetooth_c.h b/core/jni/android_bluetooth_c.h new file mode 100644 index 0000000..e890244 --- /dev/null +++ b/core/jni/android_bluetooth_c.h @@ -0,0 +1,39 @@ +/* +** Copyright 2010, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef ANDROID_BLUETOOTH_C_H +#define ANDROID_BLUETOOTH_C_H +#ifdef HAVE_BLUETOOTH + +#include <bluetooth/bluetooth.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A C helper for creating a bdaddr_t object with the value BDADDR_ANY. + * We have to do this in C because the macro BDADDR_ANY in bluetooth.h + * is not valid C++ code. + */ +bdaddr_t android_bluetooth_bdaddr_any(void); + +#ifdef __cplusplus +} +#endif + +#endif /*HAVE_BLUETOOTH*/ +#endif /*ANDROID_BLUETOOTH_C_H*/ |