Search in sources :

Example 6 with ParceledListSlice

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

the class PackageManagerService method getInstalledApplications.

@Override
public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) {
    if (!sUserManager.exists(userId))
        return ParceledListSlice.emptyList();
    flags = updateFlagsForApplication(flags, userId, null);
    final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
    // writer
    synchronized (mPackages) {
        ArrayList<ApplicationInfo> list;
        if (listUninstalled) {
            list = new ArrayList<ApplicationInfo>(mSettings.mPackages.size());
            for (PackageSetting ps : mSettings.mPackages.values()) {
                ApplicationInfo ai;
                if (ps.pkg != null) {
                    ai = PackageParser.generateApplicationInfo(ps.pkg, flags, ps.readUserState(userId), userId);
                } else {
                    ai = generateApplicationInfoFromSettingsLPw(ps.name, flags, userId);
                }
                if (ai != null) {
                    list.add(ai);
                }
            }
        } else {
            list = new ArrayList<ApplicationInfo>(mPackages.size());
            for (PackageParser.Package p : mPackages.values()) {
                if (p.mExtras != null) {
                    ApplicationInfo ai = PackageParser.generateApplicationInfo(p, flags, ((PackageSetting) p.mExtras).readUserState(userId), userId);
                    if (ai != null) {
                        list.add(ai);
                    }
                }
            }
        }
        return new ParceledListSlice<ApplicationInfo>(list);
    }
}
Also used : PackageParser(android.content.pm.PackageParser) EphemeralApplicationInfo(android.content.pm.EphemeralApplicationInfo) ApplicationInfo(android.content.pm.ApplicationInfo) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 7 with ParceledListSlice

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

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)

Example 8 with ParceledListSlice

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

the class ActivityManagerService method getGrantedUriPermissions.

@Override
public ParceledListSlice<android.content.UriPermission> getGrantedUriPermissions(String packageName, int userId) {
    enforceCallingPermission(android.Manifest.permission.GET_APP_GRANTED_URI_PERMISSIONS, "getGrantedUriPermissions");
    final ArrayList<android.content.UriPermission> result = Lists.newArrayList();
    synchronized (this) {
        final int size = mGrantedUriPermissions.size();
        for (int i = 0; i < size; i++) {
            final ArrayMap<GrantUri, UriPermission> perms = mGrantedUriPermissions.valueAt(i);
            for (UriPermission perm : perms.values()) {
                if (packageName.equals(perm.targetPkg) && perm.targetUserId == userId && perm.persistedModeFlags != 0) {
                    result.add(perm.buildPersistedPublicApiObject());
                }
            }
        }
    }
    return new ParceledListSlice<android.content.UriPermission>(result);
}
Also used : Point(android.graphics.Point) ParceledListSlice(android.content.pm.ParceledListSlice)

Example 9 with ParceledListSlice

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

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

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

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