Search in sources :

Example 1 with ParceledListSlice

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

the class PackageManagerService method getInstalledPackages.

@Override
public ParceledListSlice<PackageInfo> getInstalledPackages(int flags, int userId) {
    final boolean listUninstalled = (flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0;
    enforceCrossUserPermission(Binder.getCallingUid(), userId, true, "get installed packages");
    // writer
    synchronized (mPackages) {
        ArrayList<PackageInfo> list;
        if (listUninstalled) {
            list = new ArrayList<PackageInfo>(mSettings.mPackages.size());
            for (PackageSetting ps : mSettings.mPackages.values()) {
                PackageInfo pi;
                if (ps.pkg != null) {
                    pi = generatePackageInfo(ps.pkg, flags, userId);
                } else {
                    pi = generatePackageInfoFromSettingsLPw(ps.name, flags, userId);
                }
                if (pi != null) {
                    list.add(pi);
                }
            }
        } else {
            list = new ArrayList<PackageInfo>(mPackages.size());
            for (PackageParser.Package p : mPackages.values()) {
                PackageInfo pi = generatePackageInfo(p, flags, userId);
                if (pi != null) {
                    list.add(pi);
                }
            }
        }
        return new ParceledListSlice<PackageInfo>(list);
    }
}
Also used : PackageParser(android.content.pm.PackageParser) PackageInfo(android.content.pm.PackageInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 2 with ParceledListSlice

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

the class AppWidgetServiceImpl method startListening.

@Override
public ParceledListSlice<PendingHostUpdate> startListening(IAppWidgetHost callbacks, String callingPackage, int hostId, int[] appWidgetIds) {
    final int userId = UserHandle.getCallingUserId();
    if (DEBUG) {
        Slog.i(TAG, "startListening() " + userId);
    }
    // Make sure the package runs under the caller uid.
    mSecurityPolicy.enforceCallFromPackage(callingPackage);
    synchronized (mLock) {
        ensureGroupStateLoadedLocked(userId);
        // NOTE: The lookup is enforcing security across users by making
        // sure the caller can only access hosts it owns.
        HostId id = new HostId(Binder.getCallingUid(), hostId, callingPackage);
        Host host = lookupOrAddHostLocked(id);
        host.callbacks = callbacks;
        int N = appWidgetIds.length;
        ArrayList<PendingHostUpdate> outUpdates = new ArrayList<>(N);
        LongSparseArray<PendingHostUpdate> updatesMap = new LongSparseArray<>();
        for (int i = 0; i < N; i++) {
            if (host.getPendingUpdatesForId(appWidgetIds[i], updatesMap)) {
                // We key the updates based on request id, so that the values are sorted in the
                // order they were received.
                int M = updatesMap.size();
                for (int j = 0; j < M; j++) {
                    outUpdates.add(updatesMap.valueAt(j));
                }
            }
        }
        return new ParceledListSlice<>(outUpdates);
    }
}
Also used : LongSparseArray(android.util.LongSparseArray) ArrayList(java.util.ArrayList) IAppWidgetHost(com.android.internal.appwidget.IAppWidgetHost) Point(android.graphics.Point) PendingHostUpdate(android.appwidget.PendingHostUpdate) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 3 with ParceledListSlice

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

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 4 with ParceledListSlice

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

the class PackageManagerService method getInstalledPackages.

@Override
public ParceledListSlice<PackageInfo> getInstalledPackages(int flags, int userId) {
    if (!sUserManager.exists(userId))
        return ParceledListSlice.emptyList();
    flags = updateFlagsForPackage(flags, userId, null);
    final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
    enforceCrossUserPermission(Binder.getCallingUid(), userId, true, /* requireFullPermission */
    false, /* checkShell */
    "get installed packages");
    // writer
    synchronized (mPackages) {
        ArrayList<PackageInfo> list;
        if (listUninstalled) {
            list = new ArrayList<PackageInfo>(mSettings.mPackages.size());
            for (PackageSetting ps : mSettings.mPackages.values()) {
                final PackageInfo pi;
                if (ps.pkg != null) {
                    pi = generatePackageInfo(ps, flags, userId);
                } else {
                    pi = generatePackageInfo(ps, flags, userId);
                }
                if (pi != null) {
                    list.add(pi);
                }
            }
        } else {
            list = new ArrayList<PackageInfo>(mPackages.size());
            for (PackageParser.Package p : mPackages.values()) {
                final PackageInfo pi = generatePackageInfo((PackageSetting) p.mExtras, flags, userId);
                if (pi != null) {
                    list.add(pi);
                }
            }
        }
        return new ParceledListSlice<PackageInfo>(list);
    }
}
Also used : PackageParser(android.content.pm.PackageParser) PackageInfo(android.content.pm.PackageInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 5 with ParceledListSlice

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

the class PackageManagerService method getSystemAvailableFeatures.

@Override
@NonNull
public ParceledListSlice<FeatureInfo> getSystemAvailableFeatures() {
    synchronized (mPackages) {
        final ArrayList<FeatureInfo> res = new ArrayList<>(mAvailableFeatures.values());
        final FeatureInfo fi = new FeatureInfo();
        fi.reqGlEsVersion = SystemProperties.getInt("ro.opengles.version", FeatureInfo.GL_ES_VERSION_UNDEFINED);
        res.add(fi);
        return new ParceledListSlice<>(res);
    }
}
Also used : ArrayList(java.util.ArrayList) FeatureInfo(android.content.pm.FeatureInfo) ParceledListSlice(android.content.pm.ParceledListSlice) NonNull(android.annotation.NonNull)

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