Hi,

Look at 
android<http://www.google.com/codesearch#cZwlSNS7aEw/&exact_package=android&q=NetlinkListener&type=cs&l=34>
/system<http://www.google.com/codesearch#cZwlSNS7aEw/system/&exact_package=android&q=NetlinkListener&type=cs&l=34>
/core<http://www.google.com/codesearch#cZwlSNS7aEw/system/core/&exact_package=android&q=NetlinkListener&type=cs&l=34>
/libsysutils<http://www.google.com/codesearch#cZwlSNS7aEw/system/core/libsysutils/&exact_package=android&q=NetlinkListener&type=cs&l=34>
/src<http://www.google.com/codesearch#cZwlSNS7aEw/system/core/libsysutils/src/&exact_package=android&q=NetlinkListener&type=cs&l=34>
/NetlinkEvent.cpp

This has a function namely "decode" .. I guess this does exactly what you
want :)

For your Java Part,
What exactly you want to do in Java ?
The Parsing or receiving of the UEvent ?
Or the Complete thing you mentioned before ?

Thanks,
Durga
On Mon, Jul 18, 2011 at 7:39 PM, Hemant <[email protected]> wrote:

> Hi,
>
> Thanks for your reply.
> Well I want to write in C because I know only that..
> I wrote a small program based on netlink to receive uevent and it
> works fine. But now I am a bit confused because I am getting all
> events and not the only one.
> How can I parse an uevent message? Is there any data structure for it?
>
> If I want to do it in Java, then can you give me an example of it?
>
> Thanks/
> Hvr
>
> On Jul 18, 4:57 pm, Durgadoss Ramanathan <[email protected]>
> wrote:
> > Hi,
> >
> > Android has a UEvent Listener in the Application Framework.
> > This receives the UEvent from the Kernel.
> >
> > For BatteryStatus:
> > You may want to look at
> > frameworks/base/services/java/com/android/server/BatteryService.java
> > Similarly, also at BatteryServer.cpp(corresponding JNI..)
> >
> > Basically the battery service gets info from the JNI and packs them into
> an
> > intent
> > and broadcasts it. Intent : Action_Battery_Changed
> > You can register to listen this intent and extract every little detail
> from
> > this :)
> >
> > BTW, Nothing stops you from writing a C program that can catch
> > the UEvents. You have to write a Netlink Socket receiver..in order to do
> > that.
> >
> > Just Curious, Why you want to do that in C ?
> >
> > [If you are Ok to that in Java, then its very simple & easy..]
> >
> >
> >
> >
> >
> > On Mon, Jul 18, 2011 at 4:45 PM, Hemant <[email protected]>
> wrote:
> > > I want to handle uevent in user-space mainly for battery status
> > > changed in my application.
> > > Can this be done using C program?
> > > Can this be done by calling a select() on one of the sysfs which
> > > indicates change in battery voltage?
> > > How Android polls uevents from kernel?
> >
> > > Br/
> > > Hvr
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> > --
> > Regards
> > Durgadoss- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Regards
Durgadoss

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to