Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 257b9e45 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Null check on permission request check

This change adds a null check on PackageSetting.pkg before passing it on
to the method that checks for the QUERY_ALL_PACKAGES permission on the
package.

Test: atest AppEnumerationTests AppsFilterTest
Bug: 150405193
Change-Id: Ic92e29c685ff215f1c54dbb4aa8a0c6377a30fa7
parent 0192f737
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -964,12 +964,14 @@ public class AppsFilter {
            try {
                Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "requestsQueryAllPackages");
                if (callingPkgSetting != null) {
                    if (requestsQueryAllPackages(callingPkgSetting)) {
                        if (callingPkgSetting.pkg != null
                                && requestsQueryAllPackages(callingPkgSetting.pkg)) {
                            return false;
                        }
                } else {
                    for (int i = callingSharedPkgSettings.size() - 1; i >= 0; i--) {
                        if (requestsQueryAllPackages(callingSharedPkgSettings.valueAt(i))) {
                        AndroidPackage pkg = callingSharedPkgSettings.valueAt(i).pkg;
                        if (pkg != null && requestsQueryAllPackages(pkg)) {
                            return false;
                        }
                    }
@@ -1058,10 +1060,10 @@ public class AppsFilter {
    }


    private static boolean requestsQueryAllPackages(PackageSetting pkgSetting) {
    private static boolean requestsQueryAllPackages(@NonNull AndroidPackage pkg) {
        // we're not guaranteed to have permissions yet analyzed at package add, so we inspect the
        // package directly
        return pkgSetting.pkg.getRequestedPermissions().contains(
        return pkg.getRequestedPermissions().contains(
                Manifest.permission.QUERY_ALL_PACKAGES);
    }