【问题标题】:Activity started even it have the tag android:protectionLevel="signature"活动开始,即使它有标签 android:protectionLevel="signature"
【发布时间】:2012-03-22 10:14:21
【问题描述】:

我有 2 个应用程序“A”和“B”

应用程序“A”用证书 C_A 签名,“B”用 C_B 签名

在“A”中

    <activity android:name=".ActivityA" android:protectionLevel="signature" android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.temp.packagea" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity> 

在应用程序“B”中

        Intent i = new Intent();
        i.setAction("com.temp.package");
        startActivity(i);

问题是应用程序 A 启动时应用程序 B 没有问题。

如何保护我的应用中的启动活动免受与我的签名相同的应用的影响。

【问题讨论】:

    标签: android security android-intent certificate signing


    【解决方案1】:

    protectionLevel 不是清单中 Activity 标记的有效属性。 protectionLevel 标签适用于 &lt;permission&gt; 元素,并在您的应用程序指定新权限(不是默认的 Android 系统权限之一)时使用。

    如果应用程序未使用与包含应用程序相同的证书进行签名,您似乎正试图阻止应用程序调用 Activity(在您的示例中为 A)。您在这里要做的是通过使用&lt;permission&gt; 元素在(包含A 的应用程序的)清单中声明一个新权限,并将您的新权限的protectionLevel 设置为Signature。然后,在Activity 的清单声明中,使用android:permission 属性,以便启动Activity 需要此新权限。对于您希望能够调用Activity 的任何其他应用程序,您只需在该其他应用程序的清单中添加一个uses-permission 元素并指定您创建的新权限。由于该权限为Signature权限,安装新应用时系统会自动授予。

    【讨论】:

      【解决方案2】:

      android:protectionLevel 使用错误,应该放到权限节点中。

      【讨论】:

      • 你的意思是像这样的 吗?我试过了,但还是不行
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多