Nick
Nick

Reputation: 1138

Android NDK accessing native bluetooth functions bluedroid

I'm trying to see what sort of native bluetooth functions i can access using JNI and Android NDK. I've tried two different approaches: Using a prebuilt .so or building my own. As far as using a prebuilt .so I've pulled libbluetooth_jni.so off a Samsung Galaxy S4 using adb pull. However, I cannot find the source code for this (bluetooth_jni.c??) online and can't identify any accessible functions.

Secondly, I tried to download the source for bluedroid from
https://android.googlesource.com/platform/external/bluetooth/bluedroid/
However, I am having trouble building this.

Currently when I try to run ndk-build, I get the following errors:
undefined reference to '__android_log_print'
undefined reference to 'socket_local_client_connect'
undefined reference to 'str_parms_destroy'

I added to this line:
LOCAL_LDLIBS := -llog
and it got rid of the first error. However, I'm not sure how to get rid of the others.

Can anyone give me some advice on how to compile or otherwise get an .so in order to access native bluetooth functions??

Upvotes: 1

Views: 6870

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57183

libbluedroid is specific for some hardware; on Samsung S4 you will find different bluetooth libraries. If you need to go beyond the public bluetooth API, you will probably not find a common ground.

Another problem that you face is that these libraries cannot work in app context, as @Chris explained in his comment. They were designed to work with the media server with its special permissions.

Regarding the specific references, they are in libcutils.so. The recent discussion about this non-public library is here.

Upvotes: 1

Related Questions