summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
author 1 <mrcasey@google.com> 2023-05-08 15:23:54 +0000
committer 1 <mrcasey@google.com> 2023-05-09 14:08:51 +0000
commit79ca9efe77bf5324bcf6c6ca17f519e2eedbff86 (patch)
treef4d1e497a1622a2c7556c940826e18083b30d268 /java/src
parentd572ef6c2ba73880edecd66c86835e78763d9400 (diff)
Make app-provided chooser targets only show in the default profile
Previously if, say, a work-profile app injected a chooser target, that target would show in *both* profiles, but showing it in the opposite (personal) profile doesn't really make sense since and uses up direct share space. The placement of this code is highly-suspect but I'm avoiding changing that in this CL given the proximity to release. Bug: 280517912 Test: atest UnbundledChooserActivity Change-Id: Ia73699cde6347cd300eae388a42a2433b3840d63
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/intentresolver/ChooserActivity.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java
index 7f55f78f..95c93696 100644
--- a/java/src/com/android/intentresolver/ChooserActivity.java
+++ b/java/src/com/android/intentresolver/ChooserActivity.java
@@ -807,13 +807,20 @@ public class ChooserActivity extends ResolverActivity implements
@Override
public void addUseDifferentAppLabelIfNecessary(ResolverListAdapter adapter) {
- if (mChooserRequest.getCallerChooserTargets().size() > 0) {
- mChooserMultiProfilePagerAdapter.getActiveListAdapter().addServiceResults(
- /* origTarget */ null,
- new ArrayList<>(mChooserRequest.getCallerChooserTargets()),
- TARGET_TYPE_DEFAULT,
- /* directShareShortcutInfoCache */ Collections.emptyMap(),
- /* directShareAppTargetCache */ Collections.emptyMap());
+ if (!mChooserRequest.getCallerChooserTargets().isEmpty()) {
+ // Send the caller's chooser targets only to the default profile.
+ UserHandle defaultUser = (findSelectedProfile() == PROFILE_WORK)
+ ? getAnnotatedUserHandles().workProfileUserHandle
+ : getAnnotatedUserHandles().personalProfileUserHandle;
+ ChooserListAdapter chooserAdapter = (ChooserListAdapter) adapter;
+ if (chooserAdapter.getUserHandle() == defaultUser) {
+ chooserAdapter.addServiceResults(
+ /* origTarget */ null,
+ new ArrayList<>(mChooserRequest.getCallerChooserTargets()),
+ TARGET_TYPE_DEFAULT,
+ /* directShareShortcutInfoCache */ Collections.emptyMap(),
+ /* directShareAppTargetCache */ Collections.emptyMap());
+ }
}
}