Talking about BlueZ isolation, for RFCOMM socket or SCO it is not easy
to use same method as DBUS for HCID.
Referring to
http://source.android.com/projects/bluetooth-faq,
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
request.
Another example:
BluetoothAudioGateway.cpp is using definition RFCOMM_LM_ENCRYPT from
<bluetooth/rfcomm.h>,
static int setup_listening_socket(int dev, int channel) {
...
lm = RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT;
}
...
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
loss.
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*
env);
extern int register_android_bluetooth_RfcommSocket(JNIEnv *env);
extern int register_android_bluetooth_ScoSocket(JNIEnv *env);
extern int register_android_server_BluetoothDeviceService(JNIEnv*
env);
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.