android framework在launcher中隐藏指定app

private static final ArrayList<String> PACKAGES_REMOVE_FROM_LAUCHER  = new ArrayList<>(Arrays.asList(
        "com.qualcomm.qti.logkit.lite"
));
private @NonNull List<ResolveInfo> queryIntentActivitiesInternal(Intent intent,
        String resolvedType, int flags, int filterCallingUid, int userId,
        boolean resolveForStart, boolean allowDynamicSplits) {
        ...
// Check for results in the current profile.
result = filterIfNotSystemUser(mComponentResolver.queryActivities(
        intent, resolvedType, flags, userId), userId);

Set<String> categories  = intent.getCategories();
if (categories!= null && categories.contains(Intent.CATEGORY_LAUNCHER)
        && result.size()>0 && PACKAGES_REMOVE_FROM_LAUCHER.size()>0){
    try {
        for (int i = result.size()-1;i>=0;i--){
            ResolveInfo r = result.get(i);
            if (PACKAGES_REMOVE_FROM_LAUCHER.contains(r.activityInfo.packageName)){
                result.remove(r);
            }
        }
    } catch (Exception e){
        e.printStackTrace();
    }
    ...
}

你可能感兴趣的:(Android)