android.content.pm.ParceledListSlice Java Examples

The following examples show how to use android.content.pm.ParceledListSlice. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList = mPM.queryIntentServices(
                intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                updateFlagsForComponent(flags, userId, intent),
                userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #2
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
Example #3
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #4
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentServices(intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #5
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentContentProvidersAsUser(
        Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentContentProviders(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentContentProvidersAsUser(
        Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentContentProviders(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #7
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #8
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList = mPM.queryIntentReceivers(
                intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                updateFlagsForComponent(flags, userId, intent),
                userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList = mPM.queryIntentActivities(
                intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                updateFlagsForComponent(flags, userId, intent),
                userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #11
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentContentProvidersAsUser(
        Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentContentProviders(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #12
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
Example #13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #14
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #15
Source File: UsageStatsManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * {@hide}
 * Returns the current standby bucket of every app that has a bucket assigned to it.
 * The caller must hold the permission android.permission.PACKAGE_USAGE_STATS. The key of the
 * returned Map is the package name and the value is the bucket assigned to the package.
 * @see #getAppStandbyBucket()
 */
@SystemApi
@RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)
public Map<String, Integer> getAppStandbyBuckets() {
    try {
        final ParceledListSlice<AppStandbyInfo> slice = mService.getAppStandbyBuckets(
                mContext.getOpPackageName(), mContext.getUserId());
        final List<AppStandbyInfo> bucketList = slice.getList();
        final ArrayMap<String, Integer> bucketMap = new ArrayMap<>();
        final int n = bucketList.size();
        for (int i = 0; i < n; i++) {
            final AppStandbyInfo bucketInfo = bucketList.get(i);
            bucketMap.put(bucketInfo.mPackageName, bucketInfo.mStandbyBucket);
        }
        return bucketMap;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #16
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentServices(intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #17
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public ParceledListSlice getShortcuts(String callingPackage, long changedSince,
        String packageName, List shortcutIds, ComponentName componentName, int flags,
        UserHandle targetUser) {
    ensureShortcutPermission(callingPackage);
    if (!canAccessProfile(targetUser.getIdentifier(), "Cannot get shortcuts")) {
        return new ParceledListSlice<>(Collections.EMPTY_LIST);
    }
    if (shortcutIds != null && packageName == null) {
        throw new IllegalArgumentException(
                "To query by shortcut ID, package name must also be set");
    }

    // TODO(b/29399275): Eclipse compiler requires explicit List<ShortcutInfo> cast below.
    return new ParceledListSlice<>((List<ShortcutInfo>)
            mShortcutServiceInternal.getShortcuts(getCallingUserId(),
                    callingPackage, changedSince, packageName, shortcutIds,
                    componentName, flags, targetUser.getIdentifier(),
                    injectBinderCallingPid(), injectBinderCallingUid()));
}
 
Example #18
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #19
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentActivities(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #20
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<PackageInfo> getPackagesHoldingPermissions(
        String[] permissions, int flags) {
    final int userId = mContext.getUserId();
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getPackagesHoldingPermissions(permissions, flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #21
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private ParceledListSlice<ResolveInfo> queryActivitiesForUser(String callingPackage,
        Intent intent, UserHandle user) {
    if (!canAccessProfile(user.getIdentifier(), "Cannot retrieve activities")) {
        return null;
    }

    final int callingUid = injectBinderCallingUid();
    long ident = injectClearCallingIdentity();
    try {
        final PackageManagerInternal pmInt =
                LocalServices.getService(PackageManagerInternal.class);
        List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
                PackageManager.MATCH_DIRECT_BOOT_AWARE
                        | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                callingUid, user.getIdentifier());
        return new ParceledListSlice<>(apps);
    } finally {
        injectRestoreCallingIdentity(ident);
    }
}
 
Example #22
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #23
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #24
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<PackageInfo> getPackagesHoldingPermissions(
        String[] permissions, int flags) {
    final int userId = mContext.getUserId();
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getPackagesHoldingPermissions(permissions, flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #25
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<IntentFilter> getAllIntentFilters(String packageName) {
    try {
        ParceledListSlice<IntentFilter> parceledList =
                mPM.getAllIntentFilters(packageName);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #26
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
@SuppressWarnings("unchecked")
public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags, int userId) {
    try {
        ParceledListSlice<SharedLibraryInfo> sharedLibs = mPM.getSharedLibraries(
                mContext.getOpPackageName(), flags, userId);
        if (sharedLibs == null) {
            return Collections.emptyList();
        }
        return sharedLibs.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #27
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
@SuppressWarnings("unchecked")
public @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser(int flags, int userId) {
    try {
        ParceledListSlice<SharedLibraryInfo> sharedLibs = mPM.getSharedLibraries(
                mContext.getOpPackageName(), flags, userId);
        if (sharedLibs == null) {
            return Collections.emptyList();
        }
        return sharedLibs.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #28
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
    try {
        ParceledListSlice<PermissionGroupInfo> parceledList =
                mPM.getAllPermissionGroups(flags);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #29
Source File: PrinterDiscoverySession.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public void onPrintersRemoved(ParceledListSlice printerIds) {
    PrinterDiscoverySession session = mWeakSession.get();
    if (session != null) {
        session.mHandler.obtainMessage(MSG_PRINTERS_REMOVED,
                printerIds.getList()).sendToTarget();
    }
}
 
Example #30
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivityOptions(
    ComponentName caller, Intent[] specifics, Intent intent,
    int flags) {
    final ContentResolver resolver = mContext.getContentResolver();

    String[] specificTypes = null;
    if (specifics != null) {
        final int N = specifics.length;
        for (int i=0; i<N; i++) {
            Intent sp = specifics[i];
            if (sp != null) {
                String t = sp.resolveTypeIfNeeded(resolver);
                if (t != null) {
                    if (specificTypes == null) {
                        specificTypes = new String[N];
                    }
                    specificTypes[i] = t;
                }
            }
        }
    }

    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentActivityOptions(caller, specifics, specificTypes, intent,
                intent.resolveTypeIfNeeded(resolver), flags, mContext.getUserId());
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}