From b67757ce97ce754d02eb3c7d2c3cd2160491c29e Mon Sep 17 00:00:00 2001 From: Sarup Dalwani Date: Tue, 18 Oct 2022 10:51:45 +0000 Subject: [PATCH] For web intents, checking if parent profile can resolve. If profile have android.os.UserManager#ALLOW_PARENT_PROFILE_APP_LINKING set then parent profile should be allowed to resolve the intent even if there is no matching CrossProfileIntentFilters. Test: atest CtsDomainVerificationDeviceMultiUserTestCases Bug: 253401810 Change-Id: Ia04218df1773443b8e0692e8b2b7e0a4d516849f --- .../pm/CrossProfileIntentResolverEngine.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/pm/CrossProfileIntentResolverEngine.java b/services/core/java/com/android/server/pm/CrossProfileIntentResolverEngine.java index 3f82923763e21..7752fdffb1d78 100644 --- a/services/core/java/com/android/server/pm/CrossProfileIntentResolverEngine.java +++ b/services/core/java/com/android/server/pm/CrossProfileIntentResolverEngine.java @@ -89,8 +89,8 @@ public class CrossProfileIntentResolverEngine { /** * Resolves intent in directly linked profiles and return list of {@link CrossProfileDomainInfo} - * which contains {@link ResolveInfo}. This would also recursively call profiles not directly - * linked. + * which contains {@link ResolveInfo}. This would also iteratively call profiles not directly + * linked using Breadth First Search. * * It first finds {@link CrossProfileIntentFilter} configured in current profile to find list of * target user profiles that can serve current intent request. It uses corresponding strategy @@ -117,7 +117,23 @@ public class CrossProfileIntentResolverEngine { List matchingFilters = computer.getMatchingCrossProfileIntentFilters(intent, resolvedType, userId); - if (matchingFilters == null || matchingFilters.isEmpty()) return crossProfileDomainInfos; + if (matchingFilters == null || matchingFilters.isEmpty()) { + /** if intent is web intent, checking if parent profile should handle the intent even + if there is no matching filter. The configuration is based on user profile + restriction android.os.UserManager#ALLOW_PARENT_PROFILE_APP_LINKING **/ + if (intent.hasWebURI()) { + UserInfo parent = computer.getProfileParent(userId); + if (parent != null) { + CrossProfileDomainInfo generalizedCrossProfileDomainInfo = computer + .getCrossProfileDomainPreferredLpr(intent, resolvedType, flags, userId, + parent.id); + if (generalizedCrossProfileDomainInfo != null) { + crossProfileDomainInfos.add(generalizedCrossProfileDomainInfo); + } + } + } + return crossProfileDomainInfos; + } UserManagerInternal umInternal = LocalServices.getService(UserManagerInternal.class); UserInfo sourceUserInfo = umInternal.getUserInfo(userId);