安全内容提供者
Secure Content Provider
是否可以将内容提供者设置为只读?我知道这个问题被问过几次,但根据所有问题(例如 this),我必须编写自己的自定义写入权限。
<permission android:name="com.test.WRITE_DATABASE" android:protectionLevel="normal" />
<permission android:name="com.test.READ_DATABASE" android:protectionLevel="normal" />
//...
<provider
android:authorities="xxx"
android:name="xxx"
android:exported="true"
android:readPermission="com.test.READ_DATABASE"
android:writePermission="com.test.WRITE_DATABASE" />
但是黑客可以反编译我的应用程序并查看清单文件,然后他可以轻松地编写自己的应用程序:
<uses-permission android:name="com.test.WRITE_DATABASE" />
所以它几乎没用...
我有几个应用程序在我的 main 应用程序中使用一个内容提供程序。只有这个应用程序应该有写权限 - 其他应该只能从这个数据库中读取。有什么解决办法吗?
在此处查看有关权限的文档:https://developer.android.com/guide/topics/manifest/permission-element.html
您的问题的答案是 android:protectionLevel
属性 的权限。您可以将其设置为 signature
,这样只有使用相同密钥签名的应用程序才能请求此权限。
是否可以将内容提供者设置为只读?我知道这个问题被问过几次,但根据所有问题(例如 this),我必须编写自己的自定义写入权限。
<permission android:name="com.test.WRITE_DATABASE" android:protectionLevel="normal" />
<permission android:name="com.test.READ_DATABASE" android:protectionLevel="normal" />
//...
<provider
android:authorities="xxx"
android:name="xxx"
android:exported="true"
android:readPermission="com.test.READ_DATABASE"
android:writePermission="com.test.WRITE_DATABASE" />
但是黑客可以反编译我的应用程序并查看清单文件,然后他可以轻松地编写自己的应用程序:
<uses-permission android:name="com.test.WRITE_DATABASE" />
所以它几乎没用... 我有几个应用程序在我的 main 应用程序中使用一个内容提供程序。只有这个应用程序应该有写权限 - 其他应该只能从这个数据库中读取。有什么解决办法吗?
在此处查看有关权限的文档:https://developer.android.com/guide/topics/manifest/permission-element.html
您的问题的答案是 android:protectionLevel
属性 的权限。您可以将其设置为 signature
,这样只有使用相同密钥签名的应用程序才能请求此权限。