我试图从cpp代码向Android框架中的java代码发送一个intent . 这是我用于此目的的代码:

int ret = system("/system/bin/am broadcast -a android.intent.action.MIKE_ACCESSED --user all"); returned 256 0    
__android_log_print(ANDROID_LOG_DEBUG, "test", "Shell command returned %i %i", ret, errno);

如果SELinux处于强制模式,Logcat将返回以下内容

D/test   (  187): Shell command returned 32512 13

如果SELinux处于许可模式,Logcat将返回以下内容

D/test   (  187): Shell command returned 256 0

Errno 13对应EACCES权限被拒绝!为了能够从cpp代码进行系统调用,我需要在AOSP中进行哪些更改?请注意,源文件是在./framework/av/media/libmedia下可用的AudioSystem.cpp . 代码由mediaserver进程使用 .

来自SELinux的AVC在许可模式下

<4>[  209.136465] type=1400 audit(1427229550.386:6): avc: denied { execute } for pid=3514 comm="Binder_5" name="sh" dev="mmcblk0p25" ino=284 scontext=u:r:mediaserver:s0 tcontext=u:object_r:shell_exec:s0 tclass=file
<4>[  209.137013] type=1400 audit(1427229550.386:7): avc: denied { read open } for pid=3514 comm="Binder_5" name="sh" dev="mmcblk0p25" ino=284 scontext=u:r:mediaserver:s0 tcontext=u:object_r:shell_exec:s0 tclass=file
<4>[  209.137634] type=1400 audit(1427229550.386:8): avc: denied { execute_no_trans } for pid=3514 comm="Binder_5" path="/system/bin/sh" dev="mmcblk0p25" ino=284 scontext=u:r:mediaserver:s0 tcontext=u:object_r:shell_exec:s0 tclass=file
<4>[  209.143705] type=1400 audit(1427229550.396:9): avc: denied { execute_no_trans } for pid=3514 comm="sh" path="/system/bin/am" dev="mmcblk0p25" ino=132 scontext=u:r:mediaserver:s0 tcontext=u:object_r:system_file:s0 tclass=file
<4>[  209.156557] type=1400 audit(1427229550.406:10): avc: denied { getattr } for pid=3514 comm="am" path="/system/bin/app_process32" dev="mmcblk0p25" ino=134 scontext=u:r:mediaserver:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file
<4>[  209.156896] type=1400 audit(1427229550.406:11): avc: denied { execute } for pid=3514 comm="am" name="app_process32" dev="mmcblk0p25" ino=134 scontext=u:r:mediaserver:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file
<4>[  209.157186] type=1400 audit(1427229550.406:12): avc: denied { read open } for pid=3514 comm="am" name="app_process32" dev="mmcblk0p25" ino=134 scontext=u:r:mediaserver:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file
<4>[  209.157430] type=1400 audit(1427229550.406:13): avc: denied { execute_no_trans } for pid=3514 comm="am" path="/system/bin/app_process32" dev="mmcblk0p25" ino=134 scontext=u:r:mediaserver:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file
<4>[  209.366659] type=1400 audit(1427229550.616:14): avc: denied { execute } for pid=3514 comm="app_process" path="/data/dalvik-cache/arm/system@framework@boot.oat" dev="mmcblk0p28" ino=105876 scontext=u:r:mediaserver:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file
<7>[  215.752267] wlan0: no IPv6 routers present

非常感谢