Search in sources :

Example 16 with ProviderInfo

use of android.content.pm.ProviderInfo in project platform_frameworks_base by android.

the class ProviderTestCase2 method createProviderForTest.

/**
     * Creates and sets up a new instance of the provider.
     */
static <T extends ContentProvider> T createProviderForTest(Context context, Class<T> providerClass, String authority) throws IllegalAccessException, InstantiationException {
    T instance = providerClass.newInstance();
    ProviderInfo providerInfo = new ProviderInfo();
    providerInfo.authority = authority;
    instance.attachInfoForTesting(context, providerInfo);
    return instance;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 17 with ProviderInfo

use of android.content.pm.ProviderInfo in project platform_frameworks_base by android.

the class PackageManagerService method queryIntentContentProvidersInternal.

@NonNull
private List<ResolveInfo> queryIntentContentProvidersInternal(Intent intent, String resolvedType, int flags, int userId) {
    if (!sUserManager.exists(userId))
        return Collections.emptyList();
    flags = updateFlagsForResolve(flags, userId, intent);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        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 PackageParser.Package pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) ProviderInfo(android.content.pm.ProviderInfo) PackageParser(android.content.pm.PackageParser) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) NonNull(android.annotation.NonNull)

Example 18 with ProviderInfo

use of android.content.pm.ProviderInfo in project ShortcutBadger by leolin310148.

the class SonyHomeBadger method sonyBadgeContentProviderExists.

/**
     * Check if the latest Sony badge content provider exists .
     *
     * @param context the context to use
     * @return true if Sony badge content provider exists, otherwise false.
     */
private static boolean sonyBadgeContentProviderExists(Context context) {
    boolean exists = false;
    ProviderInfo info = context.getPackageManager().resolveContentProvider(SONY_HOME_PROVIDER_NAME, 0);
    if (info != null) {
        exists = true;
    }
    return exists;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 19 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class GetContentProvider method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    int nameIdx = getProviderNameIndex();
    String name = (String) args[nameIdx];
    int userId = VUserHandle.myUserId();
    ProviderInfo info = VPackageManager.get().resolveContentProvider(name, 0, userId);
    if (info != null && info.enabled && isAppPkg(info.packageName)) {
        int targetVPid = VActivityManager.get().initProcess(info.packageName, info.processName, userId);
        if (targetVPid == -1) {
            return null;
        }
        args[nameIdx] = StubManifest.getStubAuthority(targetVPid);
        Object holder = method.invoke(who, args);
        if (holder == null) {
            return null;
        }
        IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
        if (provider != null) {
            provider = VActivityManager.get().acquireProviderClient(userId, info);
        }
        IActivityManager.ContentProviderHolder.provider.set(holder, provider);
        IActivityManager.ContentProviderHolder.info.set(holder, info);
        return holder;
    }
    Object holder = method.invoke(who, args);
    if (holder != null) {
        IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
        info = IActivityManager.ContentProviderHolder.info.get(holder);
        if (provider != null) {
            provider = ProviderHook.createProxy(true, info.authority, provider);
        }
        IActivityManager.ContentProviderHolder.provider.set(holder, provider);
        return holder;
    }
    return null;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) IInterface(android.os.IInterface)

Example 20 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class VClientImpl method installContentProviders.

private void installContentProviders(Context app, List<ProviderInfo> providers) {
    long origId = Binder.clearCallingIdentity();
    Object mainThread = VirtualCore.mainThread();
    try {
        for (ProviderInfo cpi : providers) {
            if (cpi.enabled) {
                ActivityThread.installProvider(mainThread, app, cpi, null);
            }
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)114 RemoteException (android.os.RemoteException)36 ComponentName (android.content.ComponentName)27 PackageManager (android.content.pm.PackageManager)17 Point (android.graphics.Point)16 ArrayList (java.util.ArrayList)16 IPackageManager (android.content.pm.IPackageManager)12 ApplicationInfo (android.content.pm.ApplicationInfo)11 PackageInfo (android.content.pm.PackageInfo)10 Uri (android.net.Uri)9 PackageParser (android.content.pm.PackageParser)8 ResolveInfo (android.content.pm.ResolveInfo)8 IOException (java.io.IOException)8 ActivityInfo (android.content.pm.ActivityInfo)6 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)6 ServiceInfo (android.content.pm.ServiceInfo)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 Context (android.content.Context)5 VPackage (com.lody.virtual.server.pm.parser.VPackage)5 Map (java.util.Map)5