【问题标题】:Apk fails CTS test: shouldNotFIndUnexpectedIntents, no idea whyApk 未通过 CTS 测试:shouldNotFIndUnexpectedIntents,不知道为什么
【发布时间】:2018-05-06 05:22:04
【问题描述】:

历史:

我们的一个客户集成了我们的 Android SDK 库。他们试图通过 Google 的兼容性测试 (CTS)。

问题:

他们未能通过 CTS 测试套装并显示以下消息: android.signature.cts.intent.intentTest#shouldNotFindUnexpectedIntents |结果失败 | java.lang.AssertionError: [package their package> Invalid Intent: [android.intent.action.ACTION_BOOT_COMPLETE]]。

主要问题:

我的目标是帮助他们通过这个测试,但我不确定真正的问题是什么以及如何解决它。谁能帮忙?

详情:

1) 我目前根本无法从我们的客户那里提取有关其主机 apk 的信息。我只知道他们正在为 Android 8.0 设备 测试 priv-app apk。 (它是合法的私人应用程序,应该是)。我不能确定接下来的几天,但我相信他们的 targetSdk 是 26(即 Android 8.0.0)

2) 我们的 SDK 库包含一个广播接收器,其定义如下:

<receiver android:enabled="true" android:exported="false" android:name="<our Broadcast Receiver class path>">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
            <action android:name="com.dt.ignite.startService"/>
            <action android:name="<our package>.<our custom intent name 1>"/>
            <action android:name="<our package>.<our custom intent name 2>"/>
            <action android:name="<our package>.<our custom intent name 3>"/>
        </intent-filter>
    </receiver>

3) 查看这个特定 CTS 测试 (IntentTest.java) 的源代码,我知道它失败了,因为这个 apk 的 ApplicationInfo 包含一个不是“平台 Intent”的 Intent,特别是“BROADCAST_COMPLETE”。 (https://github.com/leolin310148/ShortcutBadger/issues/274)

4) 以上让我想到了 Google 新引入的“背景限制”以及他们如何禁止 Android 8.0 及更高版本的隐式 Intent 接收器。但是,据说 BROADCAST_COMPLETE 将不受此禁令的约束。 (https://developer.android.com/about/versions/oreo/background#broadcasts)

【问题讨论】:

    标签: android android-broadcastreceiver android-8.0-oreo cts


    【解决方案1】:

    test in question 检查清单中是否引用了不是 Platform Intents 的任何 Intents。它通过检查所有以android.intent.action 开头但不在Platform Intents 列表中的Intents。

    要通过测试,您需要从&lt;intent-filter&gt; 中删除BOOT_COMPLETED 或将其替换为合适的平台Intent

    另见此问题报告:https://github.com/leolin310148/ShortcutBadger/issues/274

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-07
      • 1970-01-01
      • 2014-10-12
      • 1970-01-01
      • 2011-06-11
      相关资源
      最近更新 更多