From 9960437e735acf0938f14e0b65fa30abb31e8973 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Tue, 28 Mar 2023 17:32:49 +0100 Subject: [PATCH] Populating ResolveInfo.UserHandle for explicit intents resolution. ResolveInfo.UserHandle was added to allow callers like sharesheet to start cross-profile activities resolutions in correct user space vis-a-vis clone profile's use case. Currently this field is only populated for implicit intents, but Sharesheet has a use case where an app can suuply initial intents as explicit ones. In this case, pm does not set the userHandle in returned ResolveInfo, causing NPE in sharesheet while starting the activity. (As sharesheet expects the userHandle to start activity be derived from resolveInfo.userHandle) This change adds the context's userHandle as the userspace to resolve explicit intents into. Bug: 273776367 Test: android.sharesheet.cts.CtsSharesheetDeviceTest Change-Id: I46a4ed84289fc7f3292ddd37342afc9b1d778214 --- services/core/java/com/android/server/pm/ComputerEngine.java | 1 + 1 file changed, 1 insertion(+) diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java index acd4a96c28173..6f7ce80e42b1c 100644 --- a/services/core/java/com/android/server/pm/ComputerEngine.java +++ b/services/core/java/com/android/server/pm/ComputerEngine.java @@ -571,6 +571,7 @@ public class ComputerEngine implements Computer { if (!blockInstantResolution && !blockNormalResolution) { final ResolveInfo ri = new ResolveInfo(); ri.activityInfo = ai; + ri.userHandle = UserHandle.of(userId); list = new ArrayList<>(1); list.add(ri); PackageManagerServiceUtils.applyEnforceIntentFilterMatching(