I was wondering how the Jack detection events are reported upto user-space. Found something while discussing it with a colleage.
VT: need your help..
VT: i observed that this file gets some notification when headphone is connected..
VT: i want to understand how that is happening..
– 12:26:12 IST –
VT: i found it.. :-) same file as you mentioned yesterday, WiredAccessoryObserver fires and Intent if a headset is plugged
TB: it will be like kernel sends the uevent/notification for detection,removal …
TB: wired accessory observer listens those and based on tht sets the current state …
VT: one more thing.. how do i enable the logging in that file?
TB: Its enabled by default …
TB: but you may not get log.v/log.d
TB: so you can convert it to log.e
TB: or either by filtering the log …
TB: using logcat options …
VT: don’t we need to enable it by using some global #defines?
VT: something like ALOG?
VT: i dont know..u r the boss
TB: tht will work in cpp
TB: this is java file :-)
VT: yea right
TB: private static final boolean LOG = true;
VT: there something called Slog.v()
TB: this lineis true
TB: change it to Slog.w/e
VT: yea right
VT: then recompile?
VT: and push the .so file, right?
TB: you may need to flash complete image
VT: but what to build then?
TB: whole source code
VT: man!! how long it will take?
TB: for anyhing you modfy in system services…
TB: ha ha ha
TB: no other option …
VT: sucks man.. can’t i only build “frameworks/base/services/java” ?
VT: it has a top level Android.mk
TB: normaly it doesn’t work …
VT: anyways, let me rebuild it
TB: we have seen it during VS service changes :-)
TB: you can try logcat options
TB: with your current build …
TB: logs are enabled by default…
VT: yea, but will it also print Slog.v ??
TB: yes …
TB: you need to use something like V:-* with logtag …
– 01:17:31 IST –
VT: dost. .
TB: bolo ne…
VT: dragon vali public aa wireaccessory manager nathi use kari
VT: they have something called windowmanager, which is used to detect accessories
VT: but i fail to understand the code of window manager.java
VT: i mean, it is a differnt file, let me send u the path
VT: vi ./frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +2646
– 01:26:41 IST –
TB: I looked the code but I am not aware from where its getting called …
VT: i got that
VT: long path.. troublesome
VT: it is using /dev/input/events* file and executes ioctls to detect the events
TB: thts how android implementation at other places as well …
VT: qualcomm guys are really weird.. i am surprised to see the code like this..
VT: just look at that file, EventHub.cpp
VT: function getEvents()
VT: it has an infinite loop
VT: anyways, it looks like i’ve figured out how jack detection works on dragonics
TB: it uses epoll_wait()
TB: so it blocks on there …
TB: whenever event is received, it continues from there …
VT: for timeoutMillis
TB: you can see similar stuff in system/core/init/ueventd.c
TB: it blocks for indefinite time