Search in sources :

Example 56 with ProviderInfo

use of android.content.pm.ProviderInfo 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 57 with ProviderInfo

use of android.content.pm.ProviderInfo in project UnityModManager by xausky.

the class ProviderIntentResolver method newResult.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected ResolveInfo newResult(VPackage.ProviderIntentInfo filter, int match, int userId) {
    final VPackage.ProviderComponent provider = filter.provider;
    PackageSetting ps = (PackageSetting) provider.owner.mExtras;
    ProviderInfo pi = PackageParserEx.generateProviderInfo(provider, mFlags, ps.readUserState(userId), userId);
    if (pi == null) {
        return null;
    }
    final ResolveInfo res = new ResolveInfo();
    res.providerInfo = pi;
    if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
        res.filter = filter.filter;
    }
    res.priority = filter.filter.getPriority();
    res.preferredOrder = provider.owner.mPreferredOrder;
    res.match = match;
    res.isDefault = filter.hasDefault;
    res.labelRes = filter.labelRes;
    res.nonLocalizedLabel = filter.nonLocalizedLabel;
    res.icon = filter.icon;
    return res;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo) TargetApi(android.annotation.TargetApi)

Example 58 with ProviderInfo

use of android.content.pm.ProviderInfo in project UnityModManager by xausky.

the class VPackageManagerService method queryContentProviders.

@Override
public VParceledListSlice<ProviderInfo> queryContentProviders(String processName, int vuid, int flags) {
    int userId = VUserHandle.getUserId(vuid);
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ArrayList<ProviderInfo> finalList = new ArrayList<>(3);
    // reader
    synchronized (mPackages) {
        for (VPackage.ProviderComponent p : mProvidersByComponent.values()) {
            PackageSetting ps = (PackageSetting) p.owner.mExtras;
            if (processName == null || ps.appId == VUserHandle.getAppId(vuid) && p.info.processName.equals(processName)) {
                ProviderInfo providerInfo = PackageParserEx.generateProviderInfo(p, flags, ps.readUserState(userId), userId);
                finalList.add(providerInfo);
            }
        }
    }
    if (!finalList.isEmpty()) {
        Collections.sort(finalList, sProviderInitOrderSorter);
    }
    return new VParceledListSlice<>(finalList);
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) VParceledListSlice(com.lody.virtual.remote.VParceledListSlice) ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList)

Example 59 with ProviderInfo

use of android.content.pm.ProviderInfo in project UnityModManager by xausky.

the class PackageParserEx method generatePackageInfo.

public static PackageInfo generatePackageInfo(VPackage p, int flags, long firstInstallTime, long lastUpdateTime, PackageUserState state, int userId) {
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    if (p.mSignatures == null) {
        readSignature(p);
    }
    PackageInfo pi = new PackageInfo();
    pi.packageName = p.packageName;
    pi.versionCode = p.mVersionCode;
    pi.sharedUserLabel = p.mSharedUserLabel;
    pi.versionName = p.mVersionName;
    pi.sharedUserId = p.mSharedUserId;
    pi.sharedUserLabel = p.mSharedUserLabel;
    pi.applicationInfo = generateApplicationInfo(p, flags, state, userId);
    pi.firstInstallTime = firstInstallTime;
    pi.lastUpdateTime = lastUpdateTime;
    if (p.requestedPermissions != null && !p.requestedPermissions.isEmpty()) {
        String[] requestedPermissions = new String[p.requestedPermissions.size()];
        p.requestedPermissions.toArray(requestedPermissions);
        pi.requestedPermissions = requestedPermissions;
    }
    if ((flags & PackageManager.GET_GIDS) != 0) {
        pi.gids = PackageParserCompat.GIDS;
    }
    if ((flags & PackageManager.GET_CONFIGURATIONS) != 0) {
        int N = p.configPreferences != null ? p.configPreferences.size() : 0;
        if (N > 0) {
            pi.configPreferences = new ConfigurationInfo[N];
            p.configPreferences.toArray(pi.configPreferences);
        }
        N = p.reqFeatures != null ? p.reqFeatures.size() : 0;
        if (N > 0) {
            pi.reqFeatures = new FeatureInfo[N];
            p.reqFeatures.toArray(pi.reqFeatures);
        }
    }
    if ((flags & PackageManager.GET_ACTIVITIES) != 0) {
        final int N = p.activities.size();
        if (N > 0) {
            int num = 0;
            final ActivityInfo[] res = new ActivityInfo[N];
            for (int i = 0; i < N; i++) {
                final VPackage.ActivityComponent a = p.activities.get(i);
                res[num++] = generateActivityInfo(a, flags, state, userId);
            }
            pi.activities = res;
        }
    }
    if ((flags & PackageManager.GET_RECEIVERS) != 0) {
        final int N = p.receivers.size();
        if (N > 0) {
            int num = 0;
            final ActivityInfo[] res = new ActivityInfo[N];
            for (int i = 0; i < N; i++) {
                final VPackage.ActivityComponent a = p.receivers.get(i);
                res[num++] = generateActivityInfo(a, flags, state, userId);
            }
            pi.receivers = res;
        }
    }
    if ((flags & PackageManager.GET_SERVICES) != 0) {
        final int N = p.services.size();
        if (N > 0) {
            int num = 0;
            final ServiceInfo[] res = new ServiceInfo[N];
            for (int i = 0; i < N; i++) {
                final VPackage.ServiceComponent s = p.services.get(i);
                res[num++] = generateServiceInfo(s, flags, state, userId);
            }
            pi.services = res;
        }
    }
    if ((flags & PackageManager.GET_PROVIDERS) != 0) {
        final int N = p.providers.size();
        if (N > 0) {
            int num = 0;
            final ProviderInfo[] res = new ProviderInfo[N];
            for (int i = 0; i < N; i++) {
                final VPackage.ProviderComponent pr = p.providers.get(i);
                res[num++] = generateProviderInfo(pr, flags, state, userId);
            }
            pi.providers = res;
        }
    }
    if ((flags & PackageManager.GET_INSTRUMENTATION) != 0) {
        int N = p.instrumentation.size();
        if (N > 0) {
            pi.instrumentation = new InstrumentationInfo[N];
            for (int i = 0; i < N; i++) {
                pi.instrumentation[i] = generateInstrumentationInfo(p.instrumentation.get(i), flags);
            }
        }
    }
    if ((flags & PackageManager.GET_SIGNATURES) != 0) {
        int N = (p.mSignatures != null) ? p.mSignatures.length : 0;
        if (N > 0) {
            pi.signatures = new Signature[N];
            System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N);
        }
    }
    return pi;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageInfo(android.content.pm.PackageInfo) ServiceInfo(android.content.pm.ServiceInfo) ProviderInfo(android.content.pm.ProviderInfo)

Example 60 with ProviderInfo

use of android.content.pm.ProviderInfo in project UnityModManager by xausky.

the class PackageParserEx method generateProviderInfo.

public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags, PackageUserState state, int userId) {
    if (p == null)
        return null;
    if (!checkUseInstalledOrHidden(state, flags)) {
        return null;
    }
    // Make shallow copies so we can store the metadata safely
    ProviderInfo pi = new ProviderInfo(p.info);
    if ((flags & PackageManager.GET_META_DATA) != 0 && (p.metaData != null)) {
        pi.metaData = p.metaData;
    }
    if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
        pi.uriPermissionPatterns = null;
    }
    pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
    return pi;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)200 ComponentName (android.content.ComponentName)43 RemoteException (android.os.RemoteException)36 ArrayList (java.util.ArrayList)33 PackageManager (android.content.pm.PackageManager)27 ResolveInfo (android.content.pm.ResolveInfo)23 ApplicationInfo (android.content.pm.ApplicationInfo)22 ServiceInfo (android.content.pm.ServiceInfo)16 Point (android.graphics.Point)16 VPackage (com.lody.virtual.server.pm.parser.VPackage)15 PackageInfo (android.content.pm.PackageInfo)14 Map (java.util.Map)14 Test (org.junit.Test)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 Uri (android.net.Uri)13 File (java.io.File)13 IPackageManager (android.content.pm.IPackageManager)12 ActivityInfo (android.content.pm.ActivityInfo)10 Before (org.junit.Before)10 Intent (android.content.Intent)8