How-to : broadcast an Intent from native daemon

1,197 views
Skip to first unread message

DonTonka

unread,
Jan 22, 2015, 10:53:26 AM1/22/15
to android-...@googlegroups.com
Hello android community,

CONTEXT
-------------------------
I have a daemon running in the native layer and I require to broadcast an Intent, so that an APK receive it and show a UI component (in my current case a notification) when a specific even occurs in my daemon. The way I was doing this in KitKat was by doing a system call to am from the daemon as below:

system
("am broadcast -a com.xxxxx.zzzzzzzzzzz.DUMMY_ACTION --ez x false");



Unfortunately, or fortunately :), since AndroidL, SELinux seems to closes the door for such behavior. I did try to give some SELinux "allow" to my daemon in order to achieve that, but unfortunately that doesn't seem to be possible on AndroidL at all because SELinux basic policies forbid it. I reach the point where I need to define an "allow" which is forbidden by SElinux policies: (allow my_daemon dalvikcache_data_file:file execute;)

libsepol.check_assertion_helper: neverallow on line 277 of external/sepolicy/domain.te (or line 5279 of policy.conf) violated by allow my_daemon dalvikcache_data_file:file { execute };


QUESTIONS
-----------------------
1) Any suggestions how can I broadcast an Intent from a native daemon? (Reminder, this is not a native android application, it is a daemon which is pure linux)
2) In case it is too complicated to broadcast an Intent in this context, any suggestions how I can achieve my goal otherwise?


Thanks!
Don T.


saranya gopal

unread,
Feb 2, 2015, 6:30:21 AM2/2/15
to android-...@googlegroups.com
One way to achieve this goal is to use binder in your native daemon to communicate with a simple APK that can broadcast the intent.
There is a very good example on how to communicate between native client and java server here:

Thanks,
Saranya
Reply all
Reply to author
Forward
0 new messages