Search in sources :

Example 46 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualXposed by android-hacker.

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 47 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualXposed by android-hacker.

the class VPackageManagerService method queryIntentContentProviders.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ProviderInfo pi = getProviderInfo(comp, flags, userId);
        if (pi != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.providerInfo = pi;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mProviders.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) TargetApi(android.annotation.TargetApi)

Example 48 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualXposed by android-hacker.

the class VPackageManagerService method resolveContentProvider.

@Override
public ProviderInfo resolveContentProvider(String name, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    synchronized (mPackages) {
        final VPackage.ProviderComponent provider = mProvidersByAuthority.get(name);
        if (provider != null) {
            PackageSetting ps = (PackageSetting) provider.owner.mExtras;
            ProviderInfo providerInfo = PackageParserEx.generateProviderInfo(provider, flags, ps.readUserState(userId), userId);
            if (providerInfo != null) {
                VPackage p = mPackages.get(providerInfo.packageName);
                PackageSetting settings = (PackageSetting) p.mExtras;
                ComponentFixer.fixComponentInfo(settings, providerInfo, userId);
                return providerInfo;
            }
        }
    }
    return null;
}
Also used : VPackage(com.lody.virtual.server.pm.parser.VPackage) ProviderInfo(android.content.pm.ProviderInfo)

Example 49 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualXposed by android-hacker.

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)

Example 50 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualXposed by android-hacker.

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)

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