Search in sources :

Example 41 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_frameworks_base by DirtyUnicorns.

the class IconUtils method loadPackageIcon.

public static Drawable loadPackageIcon(Context context, String authority, int icon) {
    if (icon != 0) {
        if (authority != null) {
            final PackageManager pm = context.getPackageManager();
            final ProviderInfo info = pm.resolveContentProvider(authority, 0);
            if (info != null) {
                return pm.getDrawable(info.packageName, icon, info.applicationInfo);
            }
        } else {
            return context.getDrawable(icon);
        }
    }
    return null;
}
Also used : PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo)

Example 42 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_frameworks_base by DirtyUnicorns.

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

use of android.content.pm.ProviderInfo in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method querySyncProviders.

/**
     * @deprecated
     */
@Deprecated
public void querySyncProviders(List<String> outNames, List<ProviderInfo> outInfo) {
    // reader
    synchronized (mPackages) {
        final Iterator<Map.Entry<String, PackageParser.Provider>> i = mProvidersByAuthority.entrySet().iterator();
        final int userId = UserHandle.getCallingUserId();
        while (i.hasNext()) {
            Map.Entry<String, PackageParser.Provider> entry = i.next();
            PackageParser.Provider p = entry.getValue();
            PackageSetting ps = mSettings.mPackages.get(p.owner.packageName);
            if (ps != null && p.syncable && (!mSafeMode || (p.info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)) {
                ProviderInfo info = PackageParser.generateProviderInfo(p, 0, ps.readUserState(userId), userId);
                if (info != null) {
                    outNames.add(entry.getKey());
                    outInfo.add(info);
                }
            }
        }
    }
}
Also used : PackageParser(android.content.pm.PackageParser) ProviderInfo(android.content.pm.ProviderInfo) Map(java.util.Map) ArrayMap(android.util.ArrayMap)

Example 44 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method installEncryptionUnawareProviders.

/**
     * When a user is unlocked, we need to install encryption-unaware providers
     * belonging to any running apps.
     */
private void installEncryptionUnawareProviders(int userId) {
    // We're only interested in providers that are encryption unaware, and
    // we don't care about uninstalled apps, since there's no way they're
    // running at this point.
    final int matchFlags = GET_PROVIDERS | MATCH_DIRECT_BOOT_UNAWARE;
    synchronized (this) {
        final int NP = mProcessNames.getMap().size();
        for (int ip = 0; ip < NP; ip++) {
            final SparseArray<ProcessRecord> apps = mProcessNames.getMap().valueAt(ip);
            final int NA = apps.size();
            for (int ia = 0; ia < NA; ia++) {
                final ProcessRecord app = apps.valueAt(ia);
                if (app.userId != userId || app.thread == null || app.unlocked)
                    continue;
                final int NG = app.pkgList.size();
                for (int ig = 0; ig < NG; ig++) {
                    try {
                        final String pkgName = app.pkgList.keyAt(ig);
                        final PackageInfo pkgInfo = AppGlobals.getPackageManager().getPackageInfo(pkgName, matchFlags, userId);
                        if (pkgInfo != null && !ArrayUtils.isEmpty(pkgInfo.providers)) {
                            for (ProviderInfo pi : pkgInfo.providers) {
                                // TODO: keep in sync with generateApplicationProvidersLocked
                                final boolean processMatch = Objects.equals(pi.processName, app.processName) || pi.multiprocess;
                                final boolean userMatch = isSingleton(pi.processName, pi.applicationInfo, pi.name, pi.flags) ? (app.userId == UserHandle.USER_SYSTEM) : true;
                                if (processMatch && userMatch) {
                                    Log.v(TAG, "Installing " + pi);
                                    app.thread.scheduleInstallProvider(pi);
                                } else {
                                    Log.v(TAG, "Skipping " + pi);
                                }
                            }
                        }
                    } catch (RemoteException ignored) {
                    }
                }
            }
        }
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 45 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_frameworks_base by AOSPA.

the class ActivityThread method installContentProviders.

private void installContentProviders(Context context, List<ProviderInfo> providers) {
    final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>();
    for (ProviderInfo cpi : providers) {
        if (DEBUG_PROVIDER) {
            StringBuilder buf = new StringBuilder(128);
            buf.append("Pub ");
            buf.append(cpi.authority);
            buf.append(": ");
            buf.append(cpi.name);
            Log.i(TAG, buf.toString());
        }
        IActivityManager.ContentProviderHolder cph = installProvider(context, null, cpi, false, /*noisy*/
        true, /*noReleaseNeeded*/
        true);
        if (cph != null) {
            cph.noReleaseNeeded = true;
            results.add(cph);
        }
    }
    try {
        ActivityManagerNative.getDefault().publishContentProviders(getApplicationThread(), results);
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException)

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