Bluetooth JNI contaminated with GPL header files?

Skip to first unread message

Jackson Fan

Mar 3, 2009, 10:55:25 PM3/3/09
to android-platform
To Google staff (maybe Nick) who work on BlueZ integration, please
confirm whether you know that GPL code is not cleanly isolated within
user space.
JNI native code examples:
are including <bluetooth/bluetooth.h> embraced by condition "#ifdef
ARCH_ARM" in 1.0 release or "#ifdef HAVE_BLUETOOTH" in cupcake.
Those 4 cpp files are claimed as Apache license, but bluetooth.h is a
BlueZ header file under GPL v2 license. So speaking from legal
perspective, license term for those 4 files should be changed to GPL
as well when compiling option HAVE_BLUETOOTH is TRUE.

- What does this mean?

If device manufacturer builds a phone with Bluetooth ON, possibly
there is a legal risk to open all user space native code. Reason is
that Bluetooth JNI as system library code, is linked up with all other
user space libraries via AndroidRuntime.cpp. For example, if one
Android device has a specific RIL implementation to enhance call
performance, then its manufacturer might be asked to open related
native code in user space.
Today we did not see HTC G1(QCOM chip based) experiencing this
problem, perhaps because the BlueZ contributor (QCOM and BlueZ people)
will not sue it. Just kidding...

BTW, I noticed that BlueZ is listed as (L)GPL usage exception in user
space, inside open source project minutes
However, from legal point of view it is a risk of contamination - code
claimed as Apache license but actually linked with GPL header files.

Jackson Fan

Mar 4, 2009, 2:45:59 AM3/4/09
to android-platform
Talking about BlueZ isolation, for RFCOMM socket or SCO it is not easy
to use same method as DBUS for HCID.
Referring to,
designer may consider BlueZ user space code either be isolated by DBUS
(Free Academic License) for HCID, or by socket for RFCOMM and SCO.
However due to the difficulty to interpret the packets with BlueZ for
sockets, JNI code still need adopt the BlueZ header file for data
structure and definition.
For example:
Function connect_work() in bluetooth_ScoSocket.cpp need use a struct
sockaddr_sco defined within <bluetooth/sco.h> like this:
struct sockaddr_sco addr;
memset(&addr, 0, sizeof(addr));
addr.sco_family = AF_BLUETOOTH;
memcpy(&addr.sco_bdaddr, BDADDR_ANY, sizeof(bdaddr_t));
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {

otherwise it is difficult to correctly indicate BlueZ about the

Another example:
BluetoothAudioGateway.cpp is using definition RFCOMM_LM_ENCRYPT from
static int setup_listening_socket(int dev, int channel) {
Although in rfcomm.h RFCOMM_LM_ENCRYPT is simply defined as 0x0004,
it is not suitable to rewrite all such value inside Apache code using
different Const name. You need redo such copying work everytime Bluez
is changing the definition.

Other technical walkarounds might be difficult either, such as pre-
allocating multiple buffers and variables to be used in about 6 JNI
cpp files, and once phone powers on to let BlueZ send a bulk of data
copying header files' content to initialize buffers and variables.
Some people ever used a proxy or agent to isolate BlueZ header files,
and "enjoy" great pain during architecture change and performance

So reasonable solution: strongly suggest Google to check with BlueZ
header file providers (Qualcomm), and get LGPL license for those
header files being used by JNI code. This way BlueZ part can become a
mixed license similar to webkit.
Additional changes after LGPL license granted, is to remove Bluetooth
APIs from AndroidRuntime.cpp which is a static link format:

extern int register_android_bluetooth_Database(JNIEnv* env);
extern int register_android_bluetooth_HeadsetBase(JNIEnv* env);
extern int register_android_bluetooth_BluetoothAudioGateway(JNIEnv*
extern int register_android_bluetooth_RfcommSocket(JNIEnv *env);
extern int register_android_bluetooth_ScoSocket(JNIEnv *env);
extern int register_android_server_BluetoothDeviceService(JNIEnv*
extern int register_android_server_BluetoothEventLoop(JNIEnv *env);
extern int register_android_server_BluetoothA2dpService(JNIEnv* env);

Then to get Bluetooth JNIs dynamically loaded as a library, like
Webkit's model. This way to avoid overall contamination because if
Bluetooth JNI is as a LGPL library, manufacturers only need open
Bluetooth related files.

Nick Pelly

Mar 4, 2009, 5:11:42 PM3/4/09

Hi Jackson,

#include <bluetooth/bluetooth.h> is only an interface contract. It
contains only constants and two trivial macros. Therefore there is no
obligation for files that include bluetooth.h to abide by the terms of
the GPL license.

We will soon replace bluetooth.h with an alternate declaration of the
interface contract that does not have the GPL header, so that this
confusion does not arise again.


Mattaku Betsujin

Mar 4, 2009, 8:10:00 PM3/4/09
Hmm, this seems to be a really loose interpretation of the GPL .....

I am not sure that triviality is a way out of your GPL obglications.

David Turner

Mar 4, 2009, 8:36:11 PM3/4/09
It's not actually so loose.

For example, any Linux distribution provides GPL-ed kernel headers that are included
by the LGPL-ed GLibc library headers, which are themselves included by any source code
that depend on the C/POSIX headers (i.e. all of them).

Mark Murphy

Mar 4, 2009, 8:41:08 PM3/4/09
> Hmm, this seems to be a really loose interpretation of the GPL .....

It's a position that's been debated off and on for over a decade.

See, for example:

To quote another similar message:

"Public domain, GPL, etc.. do not apply to non-expressive, factual matter
such as [constants and interface definitions]."

This doesn't mean everything is fine. It does mean that the position Mr.
Pelly expressed (echoed by Mr. Turner while I was writing this) is not "a
really loose interpretation". It is still up to Google/OHA and BlueZ to
settle things out.

Mark Murphy (a Commons Guy)
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

Jackson Fan

Mar 4, 2009, 9:14:01 PM3/4/09
to android-platform
Hi Nick,

As I menioned in 2nd reply, guess it is not so easy to change
with for isolation. You will have to replace all consts and structures
inside following GPL header files in a "non-apparent" way:
hci.h (this is a large one containing definitions, but you are not
using too many fields)
rfcomm.h (this is small one and data not so complex)
sco.h (this is also a small one)
I guess the walkaround from code aspect is difficult to
proceed with. Because if you just replace the name of values or
structure fields, you are still using the GPL header's file definition
- i.e., under suspicious mode.
> Nick- Hide quoted text -
> - Show quoted text -

Mike Hearn

Mar 5, 2009, 2:27:48 AM3/5/09
to android-platform
Again - you can't copyright facts, computer APIs are facts, thus
applying a license to them is meaningless.

Where it gets tricky is when headers include significant pieces of
inlined code.

I used to work on Wine and this issue came up every so often.
Importing the header files from Windows directly would have been a
copyright violation because that's an expression of facts, which *is*
protected. But rewriting them to contain those same definitions is

Jackson Fan

Apr 22, 2009, 9:48:50 PM4/22/09
to android-platform
In latest code, JNI code already links with 3 cleaned up headers
bluetooth.h, rfcomm.h and sco.h inside device\system\bluetooth\bluez-
\bluetooth. As claimed in the copyright notice, only pure facts are
listed so no copyrightable information.
Reply all
Reply to author
0 new messages