创建于安卓code(不是在Android应用程序)插座得到许可被拒绝 [英] Create a socket in android code(not in android application) getting Permission Denied
问题描述
我试图打开在Android源$ C $ C插座。具体来说,现在,我在DisplayDevice.cpp文件,但插座code中的位置可能会改变。现在经过我做的:
I am trying to open a socket in the android source code. Specifically, right now, I am in the DisplayDevice.cpp file, but the location of the socket code may change. Right now after I do:
int fd = socket(AF_INET, SOCK_STREAM, 0);
FD被返回-1,当我检查错误信息被列为拒绝权限。我环顾四周很多对于这一点,大多数的答案涉及添加Internet权限到AndroidManifest文件。这将的没有的对我工作的code,我将是Android操作系统code里面。
fd gets returned as -1, and when i check the error message it is listed as Permission Denied. I have looked around a lot for this, most answers involve adding the internet permission to the AndroidManifest file. This will not work for me as the code I am adding is inside of the android source code.
我不知道是否有一种方法可以绕过被拒绝的权限。或者,如果有更好的方法来做到这一点/使用不同类型的插口(现在我使用套接字从
I was wondering if there is a way to bypass the permission denied. Or if there is a better way to do this/ a different type of socket to use(right now I am using sockets from
感谢你。
推荐答案
这是很自然的,你得到权限被拒绝
错误。这完全是因为你没有正确的权限:)。看看<一href="http://source.android.com/tech/security/index.html#the-android-permission-model-accessing-protected-apis"相对=nofollow> Android的权限模型!
It is quite natural that you get Permission Denied
error. This is simply because you don't have correct permission :). Check out android permission model!
想象一下,就像在操作系统的普通用户一个场景,你写了一个程序,该程序试图打开一个套接字像你这样的。你很可能会面临同样的问题,这取决于指定的插座是要创建
Imagine a scenario like a normal user in an operating system and you write a program which tries to open a socket like yours. You would most probably face the same problem, depending on where the named socket is to be created.
当你要创建的插座<一href="https://android.googlesource.com/platform/frameworks/native/+/27e2562868dcd3ad26f9b4677b64ae272941704e/services/surfaceflinger/DisplayDevice.cpp"相对=nofollow> DisplayDevice.cpp (编译从源头机器人),你可能有兴趣在编译源作为超级用户。 这里是发表的 M-RIC (我从来没有测试过)。
As you are trying to create the socket in DisplayDevice.cpp (compiling android from the source), you may be interested in compiling the source as a superuser. Here is a solution posted by m-ric (I have never tested it).
一些有用的指针/而在这个迷人的课题研究,我发现用类似的方向引用:
Some useful pointers/references in similar direction and which I found useful during research on this enthralling topic are:
- <一个href="http://android.stackexchange.com/questions/18857/how-to-build-compile-su-from-source">http://android.stackexchange.com/questions/18857/how-to-build-compile-su-from-source
- execv命令=>的 HTTP://$c$c.google.com/p/superuser/source/browse/trunk/su/su.c R = 2#169
- https://github.com/ChainsDD/su-binary
- HTTP://e2e.ti。 COM /支持/ OMAP / F / 849 / P / 178679 / 648158.aspx#648158
- 从谷歌I / O 2011 http://www.youtube.com/watch视频? V = 5yorhsSPFG4
- http://android.stackexchange.com/questions/18857/how-to-build-compile-su-from-source
- execv command => http://code.google.com/p/superuser/source/browse/trunk/su/su.c?r=2#169
- https://github.com/ChainsDD/su-binary
- http://e2e.ti.com/support/omap/f/849/p/178679/648158.aspx#648158
- A video from Google I/O 2011 http://www.youtube.com/watch?v=5yorhsSPFG4
这篇关于创建于安卓code(不是在Android应用程序)插座得到许可被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!