From ff11122ddc170ef6583f39c2402d802941e1fab4 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Wed, 2 Nov 2016 10:26:45 +0000 Subject: [PATCH] DO NOT MERGE: Cross profile candidate should be considered Bug: 32547783 Fixed the regression introduced in 8e2d9d1d9050e93b15c54e992698325c7d4aa57c Test: Manual test - Open a map link in work calendar, personal map is shown as an option. Change-Id: If5651b5e09cf1916813e8f91dbdcdf53f9119ef2 (cherry picked from commit 9f2c93663c2de84f958eebef96a98458ebaf51a9) --- .../server/pm/PackageManagerService.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index d2db59d9acd09..b9d06a0a60a54 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -5398,15 +5398,23 @@ public class PackageManagerService extends IPackageManager.Stub { result.remove(xpResolveInfo); } if (result.size() == 0 && !addEphemeral) { + // No result in current profile, but found candidate in parent user. + // And we are not going to add emphemeral app, so we can return the + // result straight away. result.add(xpDomainInfo.resolveInfo); return result; } + } else if (result.size() <= 1 && !addEphemeral) { + // No result in parent user and <= 1 result in current profile, and we + // are not going to add emphemeral app, so we can return the result without + // further processing. + return result; } - if (result.size() > 1 || addEphemeral) { - result = filterCandidatesWithDomainPreferredActivitiesLPr( - intent, flags, result, xpDomainInfo, userId); - sortResult = true; - } + // We have more than one candidate (combining results from current and parent + // profile), so we need filtering and sorting. + result = filterCandidatesWithDomainPreferredActivitiesLPr( + intent, flags, result, xpDomainInfo, userId); + sortResult = true; } } else { final PackageParser.Package pkg = mPackages.get(pkgName);