android - 同步适配器服务已导出但未 protected

标签 android

开发者同仁!

我的应用程序中有一个同步适配器和一个相应的同步服务。根据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/

相关文章:

Android SDK Eclipse 错误(无法加载库)

android - 如何为 firebase teSTLab 添加 testInstrumentation 环境变量?

android - SurfaceView 与自定义 View (从 View 扩展)。 SurfaceView 比较慢,为什么?

java - 使用接口(interface)实现所有 Activity 的代码

android - 媒体播放器 : Should have subtitle controller already set: KitKat

android - uiautomatorviewer 不工作,抛出 SWT 文件夹不存在的错误

android - ContentObserver onChange() 方法被多次调用

java - 原因:failed to find target with hash string 'android-14 (Don' t have API 14 in SDK manager)

java - 按下按钮时无法加载随机图像

android - 在 ScrollView 中的 EditText 中启用滚动