Search in sources :

Example 1 with Predicate

use of com.android.internal.util.Predicate in project android_frameworks_base by DirtyUnicorns.

the class RecentsProvider method call.

@Override
public Bundle call(String method, String arg, Bundle extras) {
    if (METHOD_PURGE.equals(method)) {
        // Purge references to unknown authorities
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        final Set<String> knownAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            knownAuth.add(info.providerInfo.authority);
        }
        purgeByAuthority(new Predicate<String>() {

            @Override
            public boolean apply(String authority) {
                // Purge unknown authorities
                return !knownAuth.contains(authority);
            }
        });
        return null;
    } else if (METHOD_PURGE_PACKAGE.equals(method)) {
        // Purge references to authorities in given package
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        intent.setPackage(arg);
        final Set<String> packageAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            packageAuth.add(info.providerInfo.authority);
        }
        if (!packageAuth.isEmpty()) {
            purgeByAuthority(new Predicate<String>() {

                @Override
                public boolean apply(String authority) {
                    // Purge authority matches
                    return packageAuth.contains(authority);
                }
            });
        }
        return null;
    } else {
        return super.call(method, arg, extras);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Set(java.util.Set) Intent(android.content.Intent) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString) Predicate(com.android.internal.util.Predicate)

Example 2 with Predicate

use of com.android.internal.util.Predicate in project AnExplorer by 1hakr.

the class RecentsProvider method call.

@Override
public Bundle call(String method, String arg, Bundle extras) {
    if (METHOD_PURGE.equals(method)) {
        // Purge references to unknown authorities
        final ArraySet<String> knownAuth = new ArraySet<>();
        List<ProviderInfo> providers = getContext().getPackageManager().queryContentProviders(getContext().getPackageName(), getContext().getApplicationInfo().uid, 0);
        for (ProviderInfo providerInfo : providers) {
            knownAuth.add(providerInfo.authority);
        }
        purgeByAuthority(new Predicate<String>() {

            @Override
            public boolean apply(String authority) {
                // Purge unknown authorities
                return !knownAuth.contains(authority);
            }
        });
        return null;
    } else if (METHOD_PURGE_PACKAGE.equals(method)) {
        // Purge references to authorities in given package
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        intent.setPackage(arg);
        final ArraySet<String> packageAuth = new ArraySet<>();
        List<ProviderInfo> providers = getContext().getPackageManager().queryContentProviders(getContext().getPackageName(), getContext().getApplicationInfo().uid, 0);
        for (ProviderInfo providerInfo : providers) {
            packageAuth.add(providerInfo.authority);
        }
        if (!packageAuth.isEmpty()) {
            purgeByAuthority(new Predicate<String>() {

                @Override
                public boolean apply(String authority) {
                    // Purge authority matches
                    return packageAuth.contains(authority);
                }
            });
        }
        return null;
    } else {
        return super.call(method, arg, extras);
    }
}
Also used : ArraySet(android.support.v4.util.ArraySet) ProviderInfo(android.content.pm.ProviderInfo) Intent(android.content.Intent) List(java.util.List) DocumentInfo.getCursorString(dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString) Predicate(com.android.internal.util.Predicate)

Example 3 with Predicate

use of com.android.internal.util.Predicate in project android_frameworks_base by ParanoidAndroid.

the class InstrumentationCoreTestRunner method getBuilderRequirements.

@Override
List<Predicate<TestMethod>> getBuilderRequirements() {
    List<Predicate<TestMethod>> builderRequirements = super.getBuilderRequirements();
    Predicate<TestMethod> brokenTestPredicate = Predicates.not(new HasAnnotation(BrokenTest.class));
    builderRequirements.add(brokenTestPredicate);
    if (!singleTest) {
        Predicate<TestMethod> sideEffectPredicate = Predicates.not(new HasAnnotation(SideEffect.class));
        builderRequirements.add(sideEffectPredicate);
    }
    return builderRequirements;
}
Also used : BrokenTest(dalvik.annotation.BrokenTest) HasAnnotation(android.test.suitebuilder.annotation.HasAnnotation) TestMethod(android.test.suitebuilder.TestMethod) Predicate(com.android.internal.util.Predicate) SideEffect(dalvik.annotation.SideEffect)

Example 4 with Predicate

use of com.android.internal.util.Predicate in project android_frameworks_base by AOSPA.

the class RecentsProvider method call.

@Override
public Bundle call(String method, String arg, Bundle extras) {
    if (METHOD_PURGE.equals(method)) {
        // Purge references to unknown authorities
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        final Set<String> knownAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            knownAuth.add(info.providerInfo.authority);
        }
        purgeByAuthority(new Predicate<String>() {

            @Override
            public boolean apply(String authority) {
                // Purge unknown authorities
                return !knownAuth.contains(authority);
            }
        });
        return null;
    } else if (METHOD_PURGE_PACKAGE.equals(method)) {
        // Purge references to authorities in given package
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        intent.setPackage(arg);
        final Set<String> packageAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            packageAuth.add(info.providerInfo.authority);
        }
        if (!packageAuth.isEmpty()) {
            purgeByAuthority(new Predicate<String>() {

                @Override
                public boolean apply(String authority) {
                    // Purge authority matches
                    return packageAuth.contains(authority);
                }
            });
        }
        return null;
    } else {
        return super.call(method, arg, extras);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Set(java.util.Set) Intent(android.content.Intent) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString) Predicate(com.android.internal.util.Predicate)

Example 5 with Predicate

use of com.android.internal.util.Predicate in project android_frameworks_base by ResurrectionRemix.

the class RecentsProvider method call.

@Override
public Bundle call(String method, String arg, Bundle extras) {
    if (METHOD_PURGE.equals(method)) {
        // Purge references to unknown authorities
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        final Set<String> knownAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            knownAuth.add(info.providerInfo.authority);
        }
        purgeByAuthority(new Predicate<String>() {

            @Override
            public boolean apply(String authority) {
                // Purge unknown authorities
                return !knownAuth.contains(authority);
            }
        });
        return null;
    } else if (METHOD_PURGE_PACKAGE.equals(method)) {
        // Purge references to authorities in given package
        final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
        intent.setPackage(arg);
        final Set<String> packageAuth = Sets.newHashSet();
        for (ResolveInfo info : getContext().getPackageManager().queryIntentContentProviders(intent, 0)) {
            packageAuth.add(info.providerInfo.authority);
        }
        if (!packageAuth.isEmpty()) {
            purgeByAuthority(new Predicate<String>() {

                @Override
                public boolean apply(String authority) {
                    // Purge authority matches
                    return packageAuth.contains(authority);
                }
            });
        }
        return null;
    } else {
        return super.call(method, arg, extras);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Set(java.util.Set) Intent(android.content.Intent) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString) Predicate(com.android.internal.util.Predicate)

Aggregations

Predicate (com.android.internal.util.Predicate)5 Intent (android.content.Intent)4 ResolveInfo (android.content.pm.ResolveInfo)3 DocumentInfo.getCursorString (com.android.documentsui.model.DocumentInfo.getCursorString)3 Set (java.util.Set)3 ProviderInfo (android.content.pm.ProviderInfo)1 ArraySet (android.support.v4.util.ArraySet)1 TestMethod (android.test.suitebuilder.TestMethod)1 HasAnnotation (android.test.suitebuilder.annotation.HasAnnotation)1 BrokenTest (dalvik.annotation.BrokenTest)1 SideEffect (dalvik.annotation.SideEffect)1 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)1 List (java.util.List)1