Android的ContentProvider的读写权限 [英] Android ContentProvider read and write permissions

查看:127
本文介绍了Android的ContentProvider的读写权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在清单中,我只有一个&LT;使用-许可&GT; (<$ C C $> permission.INTERNET ),并我有两个&LT;许可&GT; 元素:

 &LT;允许机器人:名称=myapp.permission.READ
    机器人:permissionGroup =myapp.permission,group.MYAPP_DATA
    机器人:标签=@字符串/ perm_read
    机器人:说明=@字符串/ perm_read_summary
    安卓的ProtectionLevel =签名/&GT;

&LT;允许机器人:名称=myapp.permission.WRITE
    机器人:permissionGroup =myapp.permission,group.MYAPP_DATA
    机器人:标签=@字符串/ perm_write
    机器人:说明=@字符串/ perm_write_summary
    安卓的ProtectionLevel =签名/&GT;
 

再有就是提供者:

 &LT;供应商
        机器人:名称=。data.DataProvider
        机器人:多进程=真
        机器人:当局=myapp.data.DataProvider
        机器人:readPermission =myapp.permission.READ
        机器人:writePermission =myapp.permission.WRITE/&GT;
 

现在,我可以正常访问了的ContentProvider ,以及它工作得很好。

  1. 为什么,如果我没有强制使用它&LT;使用-许可&GT; ? 难道不应该被也需要在应用程序,其中的提供者是 声明?

  2. 添加&LT;使用-许可&GT; 用我自己的权限,没有什么区别。权限甚至没有列出的应用程序的信息。为什么呢?

PS:是的,我读过的问题在这里的SO和谷歌群组(那些与Hackborn回答,太)。我已经按照(因为你可以看到)什么是无处不在说明,但还是......你可以说,它的工作,但问题是正是我想看到的时候它没有。

解决方案
  

难道不应该被还需要在供应商声明的应用程序?

AFAIK,你自己的应用程序认为你声明你自己的权限。第三方将需要&LT;使用-许可&GT;

  

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

见上面。

  

您可以说,它的工作,但问题是正是我想看到的时候它没有。

另外写的应用程序在其自己的包,以测试你的权限。

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.

解决方案

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.

这篇关于Android的ContentProvider的读写权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆