Access peripherals using NDK

2,259 views
Skip to first unread message

raghu

unread,
Jan 4, 2011, 12:17:08 AM1/4/11
to android-ndk
Hi,

1) Can I access the peripherals using the NDK?

Peripherals like Camera, Wifi, GPS, USB.

2) If so, does that mean I accessing the HAL layer directly using the
applications

Thanks in advance.

Regards,
Raghu

Chris Stratton

unread,
Jan 4, 2011, 11:59:54 AM1/4/11
to android-ndk
On Jan 4, 12:17 am, raghu <raghu.narayanasw...@sasken.com> wrote:

> 1) Can I access the peripherals using the NDK?
>
> Peripherals like Camera, Wifi, GPS, USB.

Generally no, for lack of permission to access or create the device
files or load your own kernel modules and lack of public native APIs
to do so through the platform. To gain the same kind of access as
java code in android apps you may need to call back up through jni.

In the case of wifi, you can't configure it, but native code running
from a process created by an application with network permission can
use the network in the manner an unprivileged process on a more
typical linux could.

> 2) If so, does that mean I accessing the HAL layer directly using the
> applications

On a rooted or developer phone, direct access is potentially possible
- however you'd probably have to modify the android platform to
disable it's access to that peripheral first to avoid conflict. Also
you may need to load kernel drivers.

Phil Endecott

unread,
Jan 4, 2011, 2:36:20 PM1/4/11
to android-ndk
On Jan 4, 5:17 am, raghu <raghu.narayanasw...@sasken.com> wrote:
> Hi,
>
> 1) Can I access the peripherals using the NDK?
>
> Peripherals like Camera, Wifi, GPS, USB.

You can call the Java APIs for the camera and GPS using JNI. I've
done this for the GPS and it's quite straightforward.

For WiFi and USB, it depends exactly what you're trying to do...

Zoran Angelov

unread,
Jan 5, 2011, 6:37:04 AM1/5/11
to andro...@googlegroups.com
Hi,
android-cpp-sdk ( http://code.google.com/p/android-cpp-sdk/ ) can help
you to easily access peripherals from native code.
There is a sample for using the camera.

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

Phil Endecott

unread,
Jan 5, 2011, 11:35:51 AM1/5/11
to android-ndk
On Jan 5, 11:37 am, Zoran Angelov <bald...@gmail.com> wrote:
> Hi,
> android-cpp-sdk (http://code.google.com/p/android-cpp-sdk/) can help
> you to easily access peripherals from native code.
> There is a sample for using the camera.

Thanks Zoran, that is interesting. I looked for something like this
when I first started writing Android code. There are lots of tools to
make C/C++ code callable from Java, but the only one working the other
way that I could find was java4cpp (http://java4cpp.kapott.org/); that
has some problems including only supporting older versions of Java.

However, I note that like java4cpp, android-cpp-sdk has a GPL license,
so it can only be used in applications that are themselves GPL
licensed.

Zoran Angelov

unread,
Jan 10, 2011, 3:56:47 AM1/10/11
to andro...@googlegroups.com
Hi Phil,

My intention was the android-cpp-sdk to be freely available with no
restrictions.
At project creation time I had boost licence (BSL1.0
http://www.boost.org/LICENSE_1_0.txt ) on my mind, but it was not in
the list of available licences.
However, licencing now is changed to BSL1.0 and is not going to change
in the future.

Phil Endecott

unread,
Jan 10, 2011, 10:44:15 AM1/10/11
to android-ndk
On Jan 10, 8:56 am, Zoran Angelov <bald...@gmail.com> wrote:
> Hi Phil,
>
> My intention was the android-cpp-sdk to be freely available with no
> restrictions.
> At project creation time I had boost licence (BSL1.0http://www.boost.org/LICENSE_1_0.txt) on my mind, but it was not in
> the list of available licences.
> However, licencing now is changed to BSL1.0 and is not going to change
> in the future.

Thanks, I'll be investigating it some more...
Reply all
Reply to author
Forward
0 new messages