From d1b19e513ade6007688ff3afd55b531cff9219be Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Fri, 19 Apr 2024 14:27:39 -0400 Subject: Fix incorrect cross-profile share check. When this code was updated for new profiles infrastructure (ag/26444390) a mistake was made in the interpretation of (tabOwnerUserHandleForLaunch), mistaking it for 'tabOwner', ie: the user of the tab being presented. It is not. This value represents the user which launched share sheet. As a result, since this CL, no cross-profile "Blocked by IT" messages would appear when no targets are available for cross-profile sharing. The resulting UI would show an empty tab, or fall back to the "No Apps" UI message. While the UI has test coverage for this, the tests are run by forcing calls to the reponsible component to return true or false, without validation of the user ids provided. Bug: 335142494 Test: atest IntentResolver-tests-unit Flag: NONE Change-Id: I32f455611e6ae6307d49c86d480962e3426b54c3 --- java/src/com/android/intentresolver/ResolverListAdapter.java | 2 +- .../emptystate/NoCrossProfileEmptyStateProvider.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/intentresolver/ResolverListAdapter.java b/java/src/com/android/intentresolver/ResolverListAdapter.java index 9843cf8d..2a8fcfa4 100644 --- a/java/src/com/android/intentresolver/ResolverListAdapter.java +++ b/java/src/com/android/intentresolver/ResolverListAdapter.java @@ -840,7 +840,7 @@ public class ResolverListAdapter extends BaseAdapter { userHandle); } - public final List getIntents() { + public List getIntents() { // TODO: immutable copy? return mIntents; } diff --git a/java/src/com/android/intentresolver/emptystate/NoCrossProfileEmptyStateProvider.java b/java/src/com/android/intentresolver/emptystate/NoCrossProfileEmptyStateProvider.java index e6d5d1c4..2b4a7ada 100644 --- a/java/src/com/android/intentresolver/emptystate/NoCrossProfileEmptyStateProvider.java +++ b/java/src/com/android/intentresolver/emptystate/NoCrossProfileEmptyStateProvider.java @@ -34,8 +34,8 @@ import com.android.intentresolver.shared.model.User; import java.util.List; /** - * Empty state provider that does not allow cross profile sharing, it will return a blocker - * in case if the profile of the current tab is not the same as the profile of the calling app. + * Empty state provider that informs about a lack of cross profile sharing. It will return + * an empty state in case there are no intents which can be forwarded to another profile. */ public class NoCrossProfileEmptyStateProvider implements EmptyStateProvider { @@ -79,7 +79,8 @@ public class NoCrossProfileEmptyStateProvider implements EmptyStateProvider { // Allow access to the tab when launched by the same user as the tab owner // or when there is at least one target which is permitted for cross-profile. - if (launchedAsSameUser || anyCrossProfileAllowedIntents(adapter, tabOwnerHandle)) { + if (launchedAsSameUser || anyCrossProfileAllowedIntents(adapter, + /* source = */ launchedAs.getHandle())) { return null; } -- cgit v1.2.3-59-g8ed1b