在Android 5.0.1_r1中将意图从C ++发送到Java [英] Sending an intent from c++ to java in Android 5.0.1_r1
问题描述
浏览了几篇文章后,我发现我可以使用以下代码行(用于调试的第二行)发送意图:
After going through several posts I figured out I could send the intent with the following line of code (second line used for debugging):
int ret = system("am broadcast -a android.intent.action.MIKE_ACCESSED --user 0");
__android_log_print(ANDROID_LOG_DEBUG, "gxp18", "Shell command returned %i", ret);
不幸的是,这总是返回(无论系统中使用的命令是什么("...")):
Unfortunately, this returns always (No matter what is the command used in the system("...")):
Shell命令返回了32512
有趣的是,我可以使用以下命令通过adb成功发送意图:
Interestingly, I can successfully send the intent through adb using:
adb shell am broadcast -a android.intent.action.MIKE_ACCESSED
注意!我没有使用NDK.我在文章中报告的那段代码是对Android Framework中一部分代码的修改.特别是,它是Android服务之一的一部分.我正在使用AOSP并修改部分源代码.
Notice! I am not using NDK. The piece of code I reported in the post is a modification of a portion of code in the Android Framework. In particular, it is part of one of the Android services. I am working with the AOSP and modifying part of the source code.
推荐答案
1)禁用SELinux(设置为允许"模式) 2)修改ActivityManagerNative.java以绕过userId检查
1) Disable SELinux (Set in Permissive mode) 2) Modify ActivityManagerNative.java to bypass userId check
享受:)
这篇关于在Android 5.0.1_r1中将意图从C ++发送到Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!