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

Commit 683e4fa4 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[PM] Fix the NPE

If the user doesn't exist, the query result is null. Add the null
check to avoid the NPE.

Test: manual. Add a new user and delete the user.
Bug: 327151916
Change-Id: I31a8e6a5450accd87f45548c8d72058eee90f737
parent a5408c80
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -760,13 +760,18 @@ public class ComputerEngine implements Computer {
        if (pkgName == null) {
            if (!mCrossProfileIntentResolverEngine.shouldSkipCurrentProfile(this, intent,
                    resolvedType, userId)) {

                final List<ResolveInfo> queryResult = mComponentResolver.queryActivities(this,
                        intent, resolvedType, flags, userId);
                // If the user doesn't exist, the queryResult is null
                if (queryResult != null) {
                    /*
                     Check for results in the current profile only if there is no
                     {@link CrossProfileIntentFilter} for user with flag
                     {@link PackageManager.SKIP_CURRENT_PROFILE} set.
                     */
                result.addAll(filterIfNotSystemUser(mComponentResolver.queryActivities(this,
                        intent, resolvedType, flags, userId), userId));
                    result.addAll(filterIfNotSystemUser(queryResult, userId));
                }
            }
            addInstant = isInstantAppResolutionAllowed(intent, result, userId,
                    false /*skipPackageCheck*/, flags);
@@ -788,9 +793,13 @@ public class ComputerEngine implements Computer {

            if (setting != null && setting.getAndroidPackage() != null && (resolveForStart
                    || !shouldFilterApplication(setting, filterCallingUid, userId))) {
                result.addAll(filterIfNotSystemUser(mComponentResolver.queryActivities(this,
                final List<ResolveInfo> queryResult = mComponentResolver.queryActivities(this,
                        intent, resolvedType, flags, setting.getAndroidPackage().getActivities(),
                        userId), userId));
                        userId);
                // If the user doesn't exist, the queryResult is null
                if (queryResult != null) {
                    result.addAll(filterIfNotSystemUser(queryResult, userId));
                }
            }
            if (result == null || result.size() == 0) {
                // the caller wants to resolve for a particular package; however, there