我有一個內容提供者和一個測試應用程序都使用調試密鑰簽名。如果未應用權限,客戶端通常會收到內容,但我想對這些內容應用權限。所以,以下行被添加到內容供應商的清單文件:使用Android調試密鑰,protectionLevel「簽名」能否正常工作?
<permission android:name="org.example.provider.READ"
android:permissionGroup="org.example.group.DATA_ACCESS"
android:label="@string/readonlyaccess"
android:protectionLevel="signature" />
<application
...
<provider android:name=".ImageContentProvider"
android:authorities="org.example.provider"
android:readPermission="org.example.provider.READ" />
在客戶端的清單文件中添加以下行:
<uses-permission android:name="org.example.provider.READ" />
當我嘗試從供應商獲得的數據,我得到錯誤:
09-13 22:38:20.995: E/AndroidRuntime(13979): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hello/com.example.hello.HelloActivity}: java.lang.SecurityException: Permission Denial: reading org.example.ImageContentProvider uri content://org.example.provider/file from pid=13979, uid=10040 requires org.example.provider.READ
我錯過了什麼,或者它是否與應用程序由調試密鑰簽名有關?如何解決問題?我看到了向提供商添加uses-permission
的建議,但這也沒有幫助。 NB。這是在模擬器內部檢查的,如果這可能是重要的。
我找到一個相關的問題throws SecurityException when signing with the default debug keystore,但它沒有提供實際的解決方案。