开发者同仁!
我的应用程序中有一个同步适配器和一个相应的同步服务。根据Google example code,我已经声明了所有内容,包括同步服务。 .大图看起来像这样:
<service
android:name="com.myapp.SyncService"
android:exported="true"
android:process=":sync">
<intent-filter>
<action
android:name="android.content.SyncAdapter"/>
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
虽然在服务上将 android:exported
属性设置为 true
是有意义的(使 Android 系统能够访问它),但我有点困惑如何在访问权限方面限制它。除了我的应用程序和 Android 系统之外,我不希望任何其他人访问该服务。
也许我为此创建了自己的权限有点天真:
<permission
android:name="com.myapp.permission.SYNC_ADAPTER"
android:protectionLevel="signatureOrSystem" />
但仔细阅读 protectionLevel
让我更加疑惑。 Google says :
Please avoid using this option [...] "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.
所描述的场景与我的用例相去甚远。那么问题仍然存在:
我如何保护我的同步服务,以便 Android 系统(但没有第三方应用程序)可以访问它?
如有任何澄清,我们将不胜感激!
最佳答案
beworker是对的。我已经使用了签名权限,系统可以顺利同步。
关于android - 同步适配器服务已导出但未 protected ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20492078/