Android ContentProvider读写权限

发布于 2024-11-30 14:44:35 字数 1419 浏览 1 评论 0原文

权限似乎没有任何区别...

在清单中,我只有一个 (permission.INTERNET),而我有两个 元素:

<permission android:name="myapp.permission.READ"
    android:permissionGroup="myapp.permission-group.MYAPP_DATA"
    android:label="@string/perm_read"
    android:description="@string/perm_read_summary"
    android:protectionLevel="signature" />

<permission android:name="myapp.permission.WRITE"
    android:permissionGroup="myapp.permission-group.MYAPP_DATA"
    android:label="@string/perm_write"
    android:description="@string/perm_write_summary"
    android:protectionLevel="signature" />

然后是提供程序:

    <provider
        android:name=".data.DataProvider"
        android:multiprocess="true"
        android:authorities="myapp.data.DataProvider"
        android:readPermission="myapp.permission.READ"
        android:writePermission="myapp.permission.WRITE" />

现在,我可以正常访问 ContentProvider,并且它工作得很好。

  1. 如果我没有使用 强制执行,为什么它会起作用? 提供者所在的应用程序中不应该也需要它吗 声明?

  2. 使用我自己的权限添加 没有什么区别。应用程序信息中甚至没有列出权限。为什么?

ps.:是的,我已经在 SO 和 Google 网上论坛上阅读了问题(也有 Hackborn 回答的问题)。我已经遵循了(如您所见)到处描述的内容,但仍然...您可以说它有效,但重点是我想看看它什么时候不起作用。

permissions don't seem to make any difference...

In the manifest, I have only one <uses-permission> (permission.INTERNET), and I have two <permission> elements:

<permission android:name="myapp.permission.READ"
    android:permissionGroup="myapp.permission-group.MYAPP_DATA"
    android:label="@string/perm_read"
    android:description="@string/perm_read_summary"
    android:protectionLevel="signature" />

<permission android:name="myapp.permission.WRITE"
    android:permissionGroup="myapp.permission-group.MYAPP_DATA"
    android:label="@string/perm_write"
    android:description="@string/perm_write_summary"
    android:protectionLevel="signature" />

And then there is the provider:

    <provider
        android:name=".data.DataProvider"
        android:multiprocess="true"
        android:authorities="myapp.data.DataProvider"
        android:readPermission="myapp.permission.READ"
        android:writePermission="myapp.permission.WRITE" />

Right now, I have normal access to the ContentProvider, and it works just fine.

  1. Why does it work if I didn't enforce with <uses-permission>?
    Shouldn't it be needed also in the app where the provider is
    declared?

  2. Adding <uses-permission> with my own permissions make no difference. The permissions are not even listed in the app info. Why?

ps.: yes, I've read questions here on SO and on Google Groups (ones with Hackborn answering, too). I've followed (as you can see) what is described everywhere, but still... You could say that it's working, but the point is exactly that I want to see when it doesn't.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耶耶耶 2024-12-07 14:44:35

在声明提供程序的应用程序中不应该也需要它吗?

AFAIK,您自己的应用程序拥有您声明的所有权限。第三方需要

应用程序信息中甚至没有列出权限。为什么?

见上文。

你可以说它有效,但重点是我想看看它什么时候不起作用。

在自己的包中编写另一个应用程序来测试您的权限。

Shouldn't it be needed also in the app where the provider is declared?

AFAIK, your own app holds all your own permissions that you declare. Third parties would need <uses-permission>.

The permissions are not even listed in the app info. Why?

See above.

You could say that it's working, but the point is exactly that I want to see when it doesn't.

Write another app, in its own package, to test your permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文