简体   繁体   English

Android NDK,使用adb启动的纯本机应用程序的权限

[英]Android NDK, Permissions for a pure native app launched using adb

I am implementing a pure native (C++) tool using the NDK, this tool need to be able to access "/dev/graphics/fb0", and for that, I need the following permissions: 我正在使用NDK实现纯本机(C ++)工具,该工具需要能够访问“ / dev / graphics / fb0”,为此,我需要以下权限:

<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"/>
<uses-permission android:name="android.permission.READ_FRAME_BUFFER"/>

How do I specify permissions for a pure Native C++ app? 如何为纯本机C ++应用程序指定权限? ( no apk, only exe ) (无APK,仅exe)
How do I implement AndroidManifest.xml? 如何实现AndroidManifest.xml? should it get embedded in the Executable in some way? 是否应该以某种方式嵌入到可执行文件中?

You cannot specify permissions for a single executable (since it doesn't have a manifest). 您不能为单个可执行文件指定权限(因为它没有清单)。

If you run an executable, it will simply inherit the permissions of the userId it is running under. 如果运行可执行文件,它将仅继承其下运行的userId的权限。 Eg if you run it with "adb shell", if will run under the "shell" user id, which cannot access the framebuffer. 例如,如果您使用“ adb shell”运行它,则它将在“ shell”用户ID下运行,该用户ID无法访问帧缓冲区。

Your only hope is to do one of the following: 您唯一的希望是执行以下操作之一:

  • Root the device and run adb shell as root (either with 'su' or 'adb root' first). 根设备并以root身份运行adb shell(首先使用'su'或'adb root')。 This generally cannot be done with regular devices (ie those have not been flashed with a custom ROM). 通常,这对于常规设备是无法完成的(即,尚未使用自定义ROM进行刷新的设备)。

  • Create an APK that includes a VM application that will call the executable under its UID. 创建一个包含VM应用程序的APK,该VM应用程序将在其UID下调用该可执行文件。 The APK's manifest will list the corresponding permissions. APK的清单将列出相应的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM