Search in sources :

Example 36 with ParceledListSlice

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

the class PackageManagerService method queryContentProviders.

@Override
@NonNull
public ParceledListSlice<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
    final int userId = processName != null ? UserHandle.getUserId(uid) : UserHandle.getCallingUserId();
    if (!sUserManager.exists(userId))
        return ParceledListSlice.emptyList();
    flags = updateFlagsForComponent(flags, userId, processName);
    ArrayList<ProviderInfo> finalList = null;
    // reader
    synchronized (mPackages) {
        final Iterator<PackageParser.Provider> i = mProviders.mProviders.values().iterator();
        while (i.hasNext()) {
            final PackageParser.Provider p = i.next();
            PackageSetting ps = mSettings.mPackages.get(p.owner.packageName);
            if (ps != null && p.info.authority != null && (processName == null || (p.info.processName.equals(processName) && UserHandle.isSameApp(p.info.applicationInfo.uid, uid))) && mSettings.isEnabledAndMatchLPr(p.info, flags, userId)) {
                if (finalList == null) {
                    finalList = new ArrayList<ProviderInfo>(3);
                }
                ProviderInfo info = PackageParser.generateProviderInfo(p, flags, ps.readUserState(userId), userId);
                if (info != null) {
                    finalList.add(info);
                }
            }
        }
    }
    if (finalList != null) {
        Collections.sort(finalList, mProviderInitOrderSorter);
        return new ParceledListSlice<ProviderInfo>(finalList);
    }
    return ParceledListSlice.emptyList();
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) PackageParser(android.content.pm.PackageParser) ParceledListSlice(android.content.pm.ParceledListSlice) NonNull(android.annotation.NonNull)

Example 37 with ParceledListSlice

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

the class AppWidgetServiceImpl method getInstalledProvidersForProfile.

@Override
public ParceledListSlice<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter, int profileId) {
    final int userId = UserHandle.getCallingUserId();
    if (DEBUG) {
        Slog.i(TAG, "getInstalledProvidersForProfiles() " + userId);
    }
    // Ensure the profile is in the group and enabled.
    if (!mSecurityPolicy.isEnabledGroupProfile(profileId)) {
        return null;
    }
    synchronized (mLock) {
        ensureGroupStateLoadedLocked(userId);
        ArrayList<AppWidgetProviderInfo> result = new ArrayList<AppWidgetProviderInfo>();
        final int providerCount = mProviders.size();
        for (int i = 0; i < providerCount; i++) {
            Provider provider = mProviders.get(i);
            AppWidgetProviderInfo info = provider.info;
            // Ignore an invalid provider or one not matching the filter.
            if (provider.zombie || (info.widgetCategory & categoryFilter) == 0) {
                continue;
            }
            // Add providers only for the requested profile that are white-listed.
            final int providerProfileId = info.getProfile().getIdentifier();
            if (providerProfileId == profileId && mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(provider.id.componentName.getPackageName(), providerProfileId)) {
                result.add(cloneIfLocalBinder(info));
            }
        }
        return new ParceledListSlice<AppWidgetProviderInfo>(result);
    }
}
Also used : ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Point(android.graphics.Point) ParceledListSlice(android.content.pm.ParceledListSlice) WidgetBackupProvider(com.android.server.WidgetBackupProvider)

Example 38 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project android_frameworks_base by ResurrectionRemix.

the class PackageInstallerService method getMySessions.

@Override
public ParceledListSlice<SessionInfo> getMySessions(String installerPackageName, int userId) {
    mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getMySessions");
    mAppOps.checkPackage(Binder.getCallingUid(), installerPackageName);
    final List<SessionInfo> result = new ArrayList<>();
    synchronized (mSessions) {
        for (int i = 0; i < mSessions.size(); i++) {
            final PackageInstallerSession session = mSessions.valueAt(i);
            if (Objects.equals(session.installerPackageName, installerPackageName) && session.userId == userId) {
                result.add(session.generateInfo());
            }
        }
    }
    return new ParceledListSlice<>(result);
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) ArrayList(java.util.ArrayList) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 39 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project android_frameworks_base by ResurrectionRemix.

the class PackageInstallerService method getAllSessions.

@Override
public ParceledListSlice<SessionInfo> getAllSessions(int userId) {
    mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getAllSessions");
    final List<SessionInfo> result = new ArrayList<>();
    synchronized (mSessions) {
        for (int i = 0; i < mSessions.size(); i++) {
            final PackageInstallerSession session = mSessions.valueAt(i);
            if (session.userId == userId) {
                result.add(session.generateInfo());
            }
        }
    }
    return new ParceledListSlice<>(result);
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) ArrayList(java.util.ArrayList) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 40 with ParceledListSlice

use of android.content.pm.ParceledListSlice in project android_frameworks_base by crdroidandroid.

the class PackageInstallerService method getAllSessions.

@Override
public ParceledListSlice<SessionInfo> getAllSessions(int userId) {
    mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getAllSessions");
    final List<SessionInfo> result = new ArrayList<>();
    synchronized (mSessions) {
        for (int i = 0; i < mSessions.size(); i++) {
            final PackageInstallerSession session = mSessions.valueAt(i);
            if (session.userId == userId) {
                result.add(session.generateInfo());
            }
        }
    }
    return new ParceledListSlice<>(result);
}
Also used : IPackageInstallerSession(android.content.pm.IPackageInstallerSession) ArrayList(java.util.ArrayList) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Aggregations

ParceledListSlice (android.content.pm.ParceledListSlice)43 ArrayList (java.util.ArrayList)24 Point (android.graphics.Point)16 IPackageInstallerSession (android.content.pm.IPackageInstallerSession)10 PackageInfo (android.content.pm.PackageInfo)10 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)10 RemoteException (android.os.RemoteException)9 PackageParser (android.content.pm.PackageParser)7 ArraySet (android.util.ArraySet)7 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)5 PendingHostUpdate (android.appwidget.PendingHostUpdate)5 LongSparseArray (android.util.LongSparseArray)5 IAppWidgetHost (com.android.internal.appwidget.IAppWidgetHost)5 WidgetBackupProvider (com.android.server.WidgetBackupProvider)5 NonNull (android.annotation.NonNull)4 ActivityManager (android.app.ActivityManager)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 EphemeralApplicationInfo (android.content.pm.EphemeralApplicationInfo)2 FeatureInfo (android.content.pm.FeatureInfo)2 IPackageManager (android.content.pm.IPackageManager)2