Android ContentProvider读写权限
权限似乎没有任何区别...
在清单中,我只有一个
(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
,并且它工作得很好。
如果我没有使用
强制执行,为什么它会起作用? 提供者所在的应用程序中不应该也需要它吗 声明?使用我自己的权限添加
没有什么区别。应用程序信息中甚至没有列出权限。为什么?
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.
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?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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK,您自己的应用程序拥有您声明的所有权限。第三方需要
。见上文。
在自己的包中编写另一个应用程序来测试您的权限。
AFAIK, your own app holds all your own permissions that you declare. Third parties would need
<uses-permission>
.See above.
Write another app, in its own package, to test your permissions.