This of course opens up security holes.

On Thu, Dec 30, 2010 at 9:19 AM, A Curtis <[email protected]> wrote:

> I got this working!
>
> Basically I did not realize that SYSFS was more sophisticated than /
> proc and actually supported file permissions.
>
> This is basically what I did to access a GPIO from Java land.
>
> echo "128" >/sys/class/gpio/export
> echo "out" > /sys/devices/virtual/gpio/gpio128/direction
> chmod 0666 /sys/devices/virtual/gpio/gpio128/value
>
> Now you have GPIO #128 exported in sysfs, configured as an output and
> accessible to your Java application.
>
> Anything else that is accessible via sysfs can be handled in a similar
> way.
>
> Enjoy!
>
>
>
> On Dec 29, 4:36 pm, A Curtis <[email protected]> wrote:
> > Chris,
> >
> > Have you tried to access sysfs directly frdom Java? I have not been
> > able to get this to work.
> >
> > Could you provide a code fragment?
> >
> > TIA
> >
> > On Nov 23, 10:12 am, Chris Stratton <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Nov 23, 5:33 am, Mikkel Christensen <[email protected]>
> > > wrote:
> >
> > > > If the LED is already exposed in sysfs you are lucky and it should be
> > > > quite easy. Otherwise create a Kernel device driver that does the
> > > > exposure of the LED to sysfs.
> >
> > > If it's already exposed in sysfs, you don't need to use native code.
> > > You should be able to access the special file directly from java if
> > > you have the permissions set right.  If they are wrong, you can't
> > > access it from the ndk either.
> >
> > > > Then in the /jni/native.cpp function do the proper write to the sysfs
> > > > entry like this (note: this depends on how the led is exposed trough
> > > > sysfs):
> >
> > > > ret = system("echo 1 > /sys/class/leds/red/brightness");
> >
> > > Chaining the echo command seems wasteful.  Why not just write to the
> > > special file yourself?
>
> --
> unsubscribe: 
> [email protected]<android-porting%[email protected]>
> website: http://groups.google.com/group/android-porting
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to