From 9f2c93663c2de84f958eebef96a98458ebaf51a9 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Wed, 2 Nov 2016 10:26:45 +0000 Subject: [PATCH] Cross profile candidate should be considered Bug: 32547783 Fixed the regression introduced in ag/1243573 Test: Manual test - Open a map link in work calendar, personal map is shown as an option. Change-Id: If5651b5e09cf1916813e8f91dbdcdf53f9119ef2 --- .../com/android/server/pm/PackageManagerService.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 974d95d5a4ac..80639393971a 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -5417,15 +5417,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; } - } - if (result.size() > 1 || addEphemeral) { - result = filterCandidatesWithDomainPreferredActivitiesLPr( - intent, flags, result, xpDomainInfo, userId); - sortResult = true; - } + } 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; + } + // 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); -- 2.11.0