如何给出NDK/本机代码与Java相同的文件权限?

发布于 2025-01-26 23:43:10 字数 471 浏览 2 评论 0原文

我的应用程序让用户从其文档层次结构中选择intent.action_open_document的音频文件(通常在内部存储中,而不是在我的应用程序的存储中)。一旦选择,这些文件就会在双簧管中本地处理。

我有JNI工作。我可以在Java中打开文件,然后将字节码复制到本机。

但是,如果我想直接在本机代码中打开一个文件,则必须将应用程序设置为action_manage_all_all_files_access_permission。这似乎有些笨拙,这可能是因为我在uri> uri - 使用getpath() - 使用getpath()到本机,并使用fopen()

我是否有可能在不需要所有文件许可的情况下从Java端继承许可以本地打开文件?我尝试发送归档的录取器,但这并没有成功,尽管可能是我的实施。

My app is letting users select audio files with an Intent.ACTION_OPEN_DOCUMENT from within their document hierarchy (ordinarily on internal storage and not in my app's storage). The files, once selected, are then processed natively in OBOE.

I have JNI working. I can open the file in java and copy the bytecode over to native.

But if I want to open a file directly in the Native code then I must set the app to ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION. This seems a bit clumsy, it is probably because I'm sending the file path - using getPath() on the uri - to native and using fopen()?

Is it possible for me to inherit the permission from the java side to open the file natively without requiring All Files Acess permission? I tried sending a FileDescriptor over but that wasn't successful, although could have been my implementation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文