Java Code Examples for android.content.pm.PackageManager#GET_DISABLED_COMPONENTS

The following examples show how to use android.content.pm.PackageManager#GET_DISABLED_COMPONENTS . 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: Reddit.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
public static HashMap<String, String> getInstalledBrowsers() {
    int packageMatcher =
            SDK_INT >= M ? PackageManager.MATCH_ALL : PackageManager.GET_DISABLED_COMPONENTS;

    HashMap<String, String> browserMap = new HashMap<>();

    final List<ResolveInfo> resolveInfoList = getAppContext().getPackageManager()
            .queryIntentActivities(
                    new Intent(Intent.ACTION_VIEW, Uri.parse("http://ccrama.me")),
                    packageMatcher);

    for (ResolveInfo resolveInfo : resolveInfoList) {
        if (resolveInfo.activityInfo.enabled) {
            browserMap.put(resolveInfo.activityInfo.applicationInfo.packageName,
                    Reddit.getAppContext()
                            .getPackageManager()
                            .getApplicationLabel(resolveInfo.activityInfo.applicationInfo)
                            .toString());
        }
    }

    return browserMap;
}
 
Example 2
Source File: ExemptAppDataManager.java    From igniter with GNU General Public License v3.0 5 votes vote down vote up
private List<ApplicationInfo> queryCurrentInstalledApps() {
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        flags |= PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_COMPONENTS;
    } else { // These flags are deprecated since Nougat.
        flags |= PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS;
    }
    return mPackageManager.getInstalledApplications(flags);
}
 
Example 3
Source File: ApkTargetMapping.java    From GPT with Apache License 2.0 5 votes vote down vote up
/**
     * generateActivityInfo
     *
     * @param p     PackageParser.Package
     * @param pi    PackageInfo
     * @param flags flags
     */
    private void generateActivityInfo(PackageParser.Package p, PackageInfo pi, int flags) {
        PackageUserState state = new PackageUserState();

        if ((flags & PackageManager.GET_ACTIVITIES) != 0) {
            int N = p.activities.size();
            if (N > 0) {
                if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                    pi.activities = new ActivityInfo[N];
                } else {
                    int num = 0;
                    for (int i = 0; i < N; i++) {
                        if (p.activities.get(i).info.enabled) num++;
                    }
                    pi.activities = new ActivityInfo[num];
                }
                for (int i = 0, j = 0; i < N; i++) {
                    final Activity activity = p.activities.get(i);
                    if (activity.info.enabled
                            || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                        pi.activities[j++] = PackageParser.generateActivityInfo(activity, flags, state, 0);
//                        try {
//                            pi.activities[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateActivityInfo",
//                                    activity, flags, state, 0);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        } 
                    }
                }
            }
        }
    }
 
Example 4
Source File: ApkTargetMapping.java    From GPT with Apache License 2.0 5 votes vote down vote up
/**
     * generateServiceInfo
     *
     * @param p     PackageParser.Package
     * @param pi    PackageInfo
     * @param flags flags
     */
    private void generateServiceInfo(PackageParser.Package p, PackageInfo pi, int flags) {
        PackageUserState state = new PackageUserState();
        if ((flags & PackageManager.GET_SERVICES) != 0) {
            int N = p.services.size();
            if (N > 0) {
                if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                    pi.services = new ServiceInfo[N];
                } else {
                    int num = 0;
                    for (int i = 0; i < N; i++) {
                        if (p.services.get(i).info.enabled) num++;
                    }
                    pi.services = new ServiceInfo[num];
                }
                for (int i = 0, j = 0; i < N; i++) {
                    final Service service = p.services.get(i);
                    if (service.info.enabled
                            || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                        pi.services[j++] = PackageParser.generateServiceInfo(p.services.get(i), flags,
                                state, 0);
//                        try {
//                            pi.services[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateServiceInfo",
//                                    p.services.get(i), flags, state, 0);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        } 
                    }
                }
            }
        }
    }
 
Example 5
Source File: ApkTargetMapping.java    From GPT with Apache License 2.0 5 votes vote down vote up
/**
     * generateProviderInfo
     *
     * @param p     PackageParser.Package
     * @param pi    PackageInfo
     * @param flags flags
     */
    private void generateProviderInfo(PackageParser.Package p, PackageInfo pi, int flags) {
        PackageUserState state = new PackageUserState();
        if ((flags & PackageManager.GET_PROVIDERS) != 0) {
            int N = p.providers.size();
            if (N > 0) {
                if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                    pi.providers = new ProviderInfo[N];
                } else {
                    int num = 0;
                    for (int i = 0; i < N; i++) {
                        if (p.providers.get(i).info.enabled) num++;
                    }
                    pi.providers = new ProviderInfo[num];
                }
                for (int i = 0, j = 0; i < N; i++) {
                    final Provider provider = p.providers.get(i);
                    if (provider.info.enabled
                            || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                        pi.providers[j++] = PackageParser.generateProviderInfo(p.providers.get(i), flags,
                                state, 0);
//                        try {
//                            pi.providers[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateProviderInfo",
//                                    p.providers.get(i), flags, state, 0);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        } 
                    }
                }
            }
        }


    }
 
Example 6
Source File: ApkTargetMapping.java    From GPT with Apache License 2.0 5 votes vote down vote up
/**
     * generateReceiverInfo
     *
     * @param p     PackageParser.Package
     * @param pi    PackageInfo
     * @param flags flags
     */
    private void generateReceiverInfo(PackageParser.Package p, PackageInfo pi, int flags) {
        PackageUserState state = new PackageUserState();
        if ((flags & PackageManager.GET_RECEIVERS) != 0) {
            int N = p.receivers.size();
            if (N > 0) {
                if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                    pi.receivers = new ActivityInfo[N];
                } else {
                    int num = 0;
                    for (int i = 0; i < N; i++) {
                        if (p.receivers.get(i).info.enabled) num++;
                    }
                    pi.receivers = new ActivityInfo[num];
                }
                for (int i = 0, j = 0; i < N; i++) {
                    final Activity activity = p.receivers.get(i);
                    if (activity.info.enabled
                            || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) {
                        pi.receivers[j++] = PackageParser.generateActivityInfo(p.receivers.get(i), flags, state, 0);
//                        try {
//                            pi.receivers[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class,
//                                    "generateActivityInfo", p.receivers.get(i), flags, state, 0);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                    }
                }
            }
        }
    }