From c77699997d96c8810412c82b2a833f97a754bfec Mon Sep 17 00:00:00 2001 From: arangelov Date: Tue, 11 Feb 2020 18:09:48 +0000 Subject: [PATCH] Add a null check in canForwardTo for getProfileParent. PackageManagerService#canForwardTo assumes the method is called from a work profile. However, with the new changes in the intent resolver and share sheet, we use this method from the personal profile as well, in order to determine if an intent is cross-profile or not. Without this null check, we get a NPE when we call canForwardTo from the personal profile. Test: CTS tests are not relevant in this case, as PackageManagerService#canForwardTo is not a public API and the only place it's called from is IntentForwarderActivity, which does not have CTS coverage. Fixes: 149311698 Change-Id: I172f572920c258723b6a51ac35f2abc0c3aabbf8 --- .../core/java/com/android/server/pm/PackageManagerService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 8c6e6916ec868..ad70345dfc48f 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -6698,6 +6698,9 @@ public class PackageManagerService extends IPackageManager.Stub // cross-profile app linking works only towards the parent. final int callingUid = Binder.getCallingUid(); final UserInfo parent = getProfileParent(sourceUserId); + if (parent == null) { + return false; + } synchronized (mLock) { int flags = updateFlagsForResolve(0, parent.id, callingUid, false /*includeInstantApps*/);