BOARD_HAVE_BLUETOOTH := true
<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
It does not matter to me what OS to use. The current build server has
Mac Leo, Win XP, Fedora 10-32 and Fedora 10-64x
More important is what Android stuff to take... I only tried building
the java code for Android. As to building a native libraries, this
still Terra incognita for me. I never even got a confirmation that
this can be done....
Vlad
On Mon, Jun 22, 2009 at 2:12 PM, Dennis Munsie<dmu...@gmail.com> wrote:
> on the dev phone, it is definitely verifying at runtime. Those are the
> exact messages that come up when attempting to use the current way of
> calling the j9 methods. We are currently in the process of obtaining a G1
> -- I will verify the behavior once we get that phone in.
> As for building, I am currently building under OS X -- I will try to help as
> much as I can on the Linux side, but it's been a while since I've used Linux
> as my development environment.
> As for the patch, the next patches will come from svn trunk instead.
> Thanks!
> dennis
> On Mon, Jun 22, 2009 at 1:55 PM, Vlad Skarzhevskyy <skarzh...@gmail.com>
> wrote:
>>
>> The approach is fine. Only send the difs in attachment and from the
>> main svn trunk.
>> Does Dalvik verify classes only at runtime? I was under impression
>> that is is done during creation of the library.
>> If so we may need to define the J9 stuff as interfaces....
>>
>> Also would you be willing to help me to setup the build environment
>> for android on the bluecove build server (Fedora 10 32 bit). So that
>> binary would be created for android as well. We may install a
>> different VMWare appliances for this.
>>
>> Vlad
>>
>>
>>
>> On Mon, Jun 22, 2009 at 1:41 PM, Dennis Munsie<dmu...@gmail.com> wrote:
>> > Hi --
>> > I am currently running stock 1.5 (cupcake) on a dev phone. I managed to
>> > get
>> > the bluecove-gpl module compiled for android and then I had to make a
>> > few
>> > changes to the core library to get it up and running on a real phone. I
>> > am
>> > using the BlueZ libraries directly since the dbus system bus is only
>> > available to root currently.
>> > Right now, I am sorting out which changes are necessary and how to
>> > integrate
>> > them into the codebase without breaking the code on other platforms.
>> > The
>> > patch I currently have ready is below -- it's a workaround for the
>> > Dalvik VM
>> > to allow the verification to work. Since the IBM j9 classes are not
>> > available on Android, the VM will throw this error when loading the
>> > class at
>> > runtime:
>> > E/dalvikvm( 887): Could not find method
>> > com.ibm.oti.vm.VM.addShutdownClass,
>> > referenced from method
>> > com.intel.bluetooth.UtilsJavaSE.runtimeAddShutdownHook
>> > W/dalvikvm( 887): VFY: unable to resolve static method 136:
>> > Lcom/ibm/oti/vm/VM;.addShutdownClass (Ljava/lang/Runnable;)V
>> > W/dalvikvm( 887): VFY: rejecting opcode 0x71 at 0x0005
>> > W/dalvikvm( 887): VFY: rejected
>> > Lcom/intel/bluetooth/UtilsJavaSE;.runtimeAddShutdownHook
>> > (Ljava/lang/Thread;)Z
>> > W/dalvikvm( 887): Verifier rejected class
>> > Lcom/intel/bluetooth/UtilsJavaSE;
>> > This fixes that issue by moving the 2 j9 specific calls into a helper
>> > class.
>> > Since that class is never actually loaded on Dalvik, it doesn't attempt
>> > to
>> > verify that the j9 classes are there either.
>> > Please let me know if this is the preferred diff format -- I just used a
>> > diff -Naurp since I did not check out the code from SVN. I am currently
>> > working off the current 2.1.0 source tarball instead.
>> > dennis
>> > -----------------------------------------------------------
>> > diff -Naurp
>> > bluecove-2.1.0/src/main/java/com/intel/bluetooth/IBMJ9Helper.java
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/IBMJ9Helper.java
>> > --- bluecove-2.1.0/src/main/java/com/intel/bluetooth/IBMJ9Helper.java
>> > 1969-12-31 19:00:00.000000000 -0500
>> > +++
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/IBMJ9Helper.java
>> > 2009-06-22 10:11:35.000000000 -0400
>> > @@ -0,0 +1,47 @@
>> > +/**
>> > + * BlueCove - Java library for Bluetooth
>> > + * Copyright (C) 2006-2008 Vlad Skarzhevskyy
>> > + *
>> > + * Licensed to the Apache Software Foundation (ASF) under one
>> > + * or more contributor license agreements. See the NOTICE file
>> > + * distributed with this work for additional information
>> > + * regarding copyright ownership. The ASF licenses this file
>> > + * to you 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.
>> > + *
>> > + * @author dmunsie
>> > + * @version $Id$
>> > + */
>> > +package com.intel.bluetooth;
>> > +
>> > +import com.ibm.oti.vm.VM;
>> > +
>> > +import java.io.IOException;
>> > +
>> > +/**
>> > + *
>> > + * IBM J9 helper module.
>> > + *
>> > + * <p>
>> > + * <b><u>Your application should not use this class directly.</u></b>
>> > + */
>> > +public class IBMJ9Helper {
>> > +
>> > + public static synchronized void loadLibrary(String libname) throws
>> > IOException {
>> > + VM.loadLibrary(libname);
>> > + }
>> > +
>> > + public static void addShutdownClass(Runnable hook) {
>> > + VM.addShutdownClass(hook);
>> > + }
>> > +}
>> > diff -Naurp
>> > bluecove-2.1.0/src/main/java/com/intel/bluetooth/NativeLibLoader.java
>> >
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/NativeLibLoader.java
>> > ---
>> > bluecove-2.1.0/src/main/java/com/intel/bluetooth/NativeLibLoader.java
>> > 2008-12-24 11:58:34.000000000 -0500
>> > +++
>> >
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/NativeLibLoader.java
>> > 2009-06-22 10:05:34.000000000 -0400
>> > @@ -30,8 +30,6 @@ import java.io.IOException;
>> > import java.io.InputStream;
>> > import java.util.Hashtable;
>> >
>> > -import com.ibm.oti.vm.VM;
>> > -
>> > /**
>> > * Load native library from resources.
>> > *
>> > @@ -226,7 +224,7 @@ public abstract class NativeLibLoader {
>> >
>> > private static boolean tryloadIBMj9MIDP(String name) {
>> > try {
>> > - VM.loadLibrary(name);
>> > + IBMJ9Helper.loadLibrary(name);
>> > DebugLog.debug("Library loaded", name);
>> > } catch (Throwable e) {
>> > DebugLog.error("Library " + name + " not loaded ", e);
>> > @@ -253,7 +251,7 @@ public abstract class NativeLibLoader {
>> >
>> > private static boolean tryloadPathIBMj9MIDP(String path, String name)
>> > {
>> > try {
>> > - VM.loadLibrary(path + "\\" + name);
>> > + IBMJ9Helper.loadLibrary(path + "\\" + name);
>> > DebugLog.debug("Library loaded", path + "\\" + name);
>> > } catch (Throwable e) {
>> > DebugLog.error("Can't load library from path " + path + "\\" + name,
>> > e);
>> > diff -Naurp
>> > bluecove-2.1.0/src/main/java/com/intel/bluetooth/UtilsJavaSE.java
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/UtilsJavaSE.java
>> > --- bluecove-2.1.0/src/main/java/com/intel/bluetooth/UtilsJavaSE.java
>> > 2008-12-24 11:58:34.000000000 -0500
>> > +++
>> > bluecove-2.1.0-ibm/src/main/java/com/intel/bluetooth/UtilsJavaSE.java
>> > 2009-06-22 10:09:08.000000000 -0400
>> > @@ -28,8 +28,6 @@ import java.security.PrivilegedActionExc
>> > import java.util.Properties;
>> > import java.util.Vector;
>> >
>> > -import com.ibm.oti.vm.VM;
>> > -
>> > /**
>> > *
>> > * J2ME/J9 compatibility module.
>> > @@ -188,7 +186,7 @@ public class UtilsJavaSE {
>> > // since Java 1.3
>> > if (!javaSECompiledOut) {
>> > if (ibmJ9midp) {
>> > - VM.addShutdownClass(thread);
>> > + IBMJ9Helper.addShutdownClass(thread);
>> > return true;
>> > } else {
>> > Runtime.getRuntime().addShutdownHook(thread);
>> >
>> >
>> > On Mon, Jun 22, 2009 at 1:22 PM, Vlad Skarzhevskyy
>> > <skarzh...@gmail.com>
>> > wrote:
>> >>
>> >> Hi Dennis,
>> >> It would be very interesting to know how you have done this. Is this
>> >> for Android cupcake or for your own version of Android firmware?
>> >>
>> >> Definitely send the changes to the group I would add them to the
>> >> BlueCove main line.
>> >>
>> >> If you wish to work directly with BlueCove SVN please send the
>> >> changes for review first. Once I see that changes are applicable and
>> >> you are reliable commiter you would be granted access to svn ....
>> >>
>> >> Don't forget that any changes made to the common code should not
>> >> break existing functionality on other platforms.
>> >>
>> >> Vlad
>> >>
>> >>
>> >>
>> >> On Mon, Jun 22, 2009 at 12:19 PM, Dennis<dmu...@gmail.com> wrote:
>> >> > Hi --
>> >> >
>> >> > My name is Dennis Munsie -- I am a software engineer at a company
>> >> > that
>> >> > is very interested in making our device work with Android, and as
>> >> > such, I have been working on porting Bluecove to run atop Android and
>> >> > the Dalvik VM. Currently, I am able to use our own proprietary
>> >> > library running atop Bluecove on the Android dev phone running within
>> >> > the standard Android sandbox without any root privileges.
>> >> >
>> >> > I currently have a patch that I would like to submit and I will be
>> >> > working on more over the next week as I go through and put proper
>> >> > fixes in place rather than the bandaids that I currently have
>> >> > employed
>> >> > to get things up and running.
>> >> >
>> >> > Thanks!
>> >> > dennis
>> >
>> >
>
>
>
> --
> dennis
>
This is what I think. Since we create the file name libbluecove.so
for regular Linux 32 bit and for Android it may be confusing for
users and also would be a problematic for automated build to have two
files by the same name.
I would suggest to change the name to be consistent with other
"os.arch" driven names as I have for other systems. The
libbluecove_arm.so would be OK if Android was a standard Linux system.
So I suggest to have it named libbluecove_android_arm.so or
libbluecovea_arm.so. Now the System.getProperty("os.arch") has a bug
on Android and does not return a proper value.... I believe that
there would definitely be a Intel build of Android in a future so we
should come prepared.
Vlad
PS
Thanks for changing the subject.
Vlad
dennis
--
dennis
- The bluecove-gpl module stay GPL. Nothing changes with android!
BlueZ is GPL and if you link with it you get GPL....
Android NDK binaries are under GPL.
Android Linux kernel is GPL, Linux is GPL nothing change here.
Google went a long road to make SDK under Apache license, You see
they even don't use Java on device.
- 'bluecove-android'
The special android module should be considered for creating android
library that can be used by other applications to access bluetooth.
As to what API this module should expose it is a different story
probably only JSR-82 if it is possible.
I don't see that there would be much code special for android. It
should reuse existing bluecove and bluecove-gpl modules and just
create an distributable android library APK.
- Another mandatory module is 'bluecove-tester' for Android.
I don't know if I personally would have much time to do all this this
summer. So a help from the group is required.
Mina back to making a first build.
- To the best of my knowledge android-ndk does not contain bluez
headers and library for linking. How you went around this?
- Dennis patches has been applied to trunk so the bluecove sources
should be used.
- As to Log4j integration we should probably change to slf4j if possible.
Can we used the same approach for Android and redirect our log
calls to android.util.Log.
To the best of my knowledge Class.forName() should work fine on
android. What was your problem exactly?
- The android specific #ifdef in C code should also solve the problem
Vlad
- BlueZ headers will be in <android-source-tree>/external/bluez/libs/include. Copy or symlink "bluetooth" directory to <android-ndk>/build/platforms/android-1.5/arch-arm/usr/include
- libbluetooth.so will be in <android-source-tree>/out/target/product/generic/system/lib. libdl.so will be in same path
About the build instructions, you don't mention to
ln -s <android-source-tree>/system/core/include/cutils
<android-ndk>sources/bluecove
so I get:
Android NDK: Building for application 'bluecove'
Compile thumb : bluecove <= sources/bluecove/BlueCoveBlueZ.c
In file included from sources/bluecove/BlueCoveBlueZ.h:34,
from sources/bluecove/BlueCoveBlueZ.c:23:
build/platforms/android-1.5/arch-arm/usr/include/bluetooth/sdp.h:35:28:
warning: cutils/sockets.h: No such file or directory
In file included from sources/bluecove/BlueCoveBlueZ.c:23:
"BlueCoveBlueZ.h" --> #include <bluetooth/sdp.h>
sdp.h --> #include <cutils/sockets.h>
Is my build wrong?
Is my sdp.h different than yours?
Shawn
>> > 1. From android-ndk documentation, to build with android-ndk we
>> > need to put source files under <android-ndk>/sources/<app-name>
>> > and application descriptor under <android-ndk>/apps/<app-name>.
>> > Symlinks work fine. So, create <android-ndk>/sources/bluecove
>> > and <android-ndk>/apps/bluecove.
>> > 2. download and build android source tree as Dennis described in a
>> > previous mail to get bluez headers and libbluetooth.so.
>> >
>> > * BlueZ headers will be in
>> > <android-source-tree>/external/bluez/libs/include. Copy
>> > or symlink "bluetooth" directory to
>> >
>> > <android-ndk>/build/platforms/android-1.5/arch-arm/usr/include
>> > * libbluetooth.so will be in
>> >
>> > <android-source-tree>/out/target/product/generic/system/lib. libdl.so will
>> > be in same path
>> >
>> > 3. Add Android.mk file to <android-ndk>/sources/bluecove/ (my
>> > Android.mk is attached).
>> > 4. Add Application.mk file to <android-ndk>/apps/bluecove/ (my
>> > Application.mk is attached).
>> > 5. Copy or symlink libbluetooth.so to
>> > <android-ndk>/out/apps/bluecove/android-1.5-arm/ (create this
>> > path if doesn't exist). and same for libdl.so (it was linker not
>> > compiler who complained about dlopen, dlsym, and dlclose and
>> > this solved by linking to libdl.so).
>> > 6. Starting from <android-ndk> directory type in terminal "make
>> > APP=bluecove"
>> > 7. Without any change to trunk code (after Dennis patch). it builds
>> > although I see some warnings in build process that I haven't
>> > gave them time to examine till now.
>> > 8. copy libbluecove.so to any android project under
>> > <project-path>/libs/armeabi/ and add bluecove-<...>.jar and
>> > bluecove-gpl-<...>.jar to classpath of application and it should
>> > work. (Does anyone know how to build a .apk package for bluecove
>> > and export its APIs to other applications?)
>> > 9. Emulator doesn't have libbluetooth.so, so this will work only
>> > Android.mk
>> > < 1KViewDownload
>> >
>> > Application.mk
>> > < 1KViewDownload
>
I checked out svn and ran the ant build script.
Bluecove builds fine. Bluecove-gpl reports:
BLUECOVE_TRUNK/bluecove-gpl/src/main/java/com/intel/bluetooth/
BluetoothStackBlueZ.java:41: com.intel.bluetooth.BluetoothStackBlueZ
is not abstract and does not override abstract method l2Send(long,byte
[]) in com.intel.bluetooth.BluetoothStack
class BluetoothStackBlueZ implements BluetoothStack,
BluetoothStackExtension {.......
Shawn