leolin310148 / ShortcutBadger

An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.
Other
7.35k stars 1.34k forks source link

Usage of the library will lead to shouldNotFindUnexpectedIntents test fail in CTS 8.x #274

Open AlexStarc opened 6 years ago

AlexStarc commented 6 years ago

There's the following test in CTS 8.x

http://androidxref.com/8.0.0_r4/xref/cts/tests/signature/src/android/signature/cts/IntentTest.java#107

@RunWith(AndroidJUnit4.class)
public class IntentTest {
    private static final String TAG = IntentTest.class.getSimpleName();

    private static final File SIGNATURE_TEST_PACKGES =
            new File("/data/local/tmp/signature-test-packages");
    private static final String ANDROID_INTENT_PREFIX = "android.intent.action";

...

    @Test
    public void shouldNotFindUnexpectedIntents() throws Exception {
        Set<String> platformIntents = lookupPlatformIntents();
        platformIntents.addAll(intentWhitelist);

        Set<String> allInvalidIntents = new HashSet<>();

        Set<String> errors = new HashSet<>();
        List<ApplicationInfo> packages =
            mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
        for (ApplicationInfo appInfo : packages) {
            if (!isSystemApp(appInfo) && !isUpdatedSystemApp(appInfo)) {
                // Only examine system apps
                continue;
            }
            Set<String> invalidIntents = new HashSet<>();
            Set<String> activeIntents = lookupActiveIntents(appInfo.packageName);

            for (String activeIntent : activeIntents) {
              String intent = activeIntent.trim();
              if (!platformIntents.contains(intent) &&
                    intent.startsWith(ANDROID_INTENT_PREFIX)) {
                  invalidIntents.add(activeIntent);
                  allInvalidIntents.add(activeIntent);
              }
            }

            String error = String.format("Package: %s Invalid Intent: %s",
                  appInfo.packageName, invalidIntents);
            if (!invalidIntents.isEmpty()) {
                errors.add(error);
            }
        }

...

Note that it checks intent which starts with "android.intent.action".

So, if device with some launcher which wants to show badges (and so, has broadcast for action 'android.intent.action.BADGE_COUNT_UPDATE') it will definitely fail this CTS case.

AlexStarc commented 6 years ago

Seems, this issue contains explanation for #245 #252