diff options
| author | 2023-03-13 12:28:41 +0000 | |
|---|---|---|
| committer | 2023-03-13 12:28:41 +0000 | |
| commit | e7f8555d956c8bf5f338a182d8023b2740edc389 (patch) | |
| tree | 46384e339f062db6cf7f1b1e125437b79bdd37fa /java/src | |
| parent | 27f4361257d87fcdc5093fd3a2ba15071bcb5412 (diff) | |
Allow refinement of caller-provided chooser targets
More specifically, this provides refinement behavior for any
`SelectableTargetInfo` targets that weren't joined to a
`DisplayResolveInfo` in our intent-resolution step. AFAIK this is
only for the caller's `EXTRA_CHOOSER_TARGETS`.
CTS coverage is provided by the pending ag/21973239 (in the same
topic as this CL).
Bug: 271149302
Test: `atest CtsSharesheetDeviceTest`. New
`testChooserTargetsRefinement` (pending in the same topic) exercises
the fix from this CL, or fails without that fix.
Change-Id: Ie7772953e63fe69dfe080f75eb73ac795693b1ad
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/chooser/SelectableTargetInfo.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/java/src/com/android/intentresolver/chooser/SelectableTargetInfo.java b/java/src/com/android/intentresolver/chooser/SelectableTargetInfo.java index e8847edc..74c19e67 100644 --- a/java/src/com/android/intentresolver/chooser/SelectableTargetInfo.java +++ b/java/src/com/android/intentresolver/chooser/SelectableTargetInfo.java @@ -195,13 +195,13 @@ public final class SelectableTargetInfo extends ChooserTargetInfo { mResolvedComponentName = getResolvedComponentName(mSourceInfo, mBackupResolveInfo); - mAllSourceIntents = getAllSourceIntents(sourceInfo); - mBaseIntentToSend = getBaseIntentToSend( baseIntentToSend, mResolvedIntent, mReferrerFillInIntent); + mAllSourceIntents = getAllSourceIntents(sourceInfo, mBaseIntentToSend); + mHashProvider = context -> { final String plaintext = getChooserTargetComponentName().getPackageName() @@ -395,12 +395,24 @@ public final class SelectableTargetInfo extends ChooserTargetInfo { return sb.toString(); } - private static List<Intent> getAllSourceIntents(@Nullable DisplayResolveInfo sourceInfo) { + private static List<Intent> getAllSourceIntents( + @Nullable DisplayResolveInfo sourceInfo, Intent fallbackSourceIntent) { final List<Intent> results = new ArrayList<>(); if (sourceInfo != null) { results.addAll(sourceInfo.getAllSourceIntents()); + } else { + // This target wasn't joined to a `DisplayResolveInfo` result from our intent-resolution + // step, so it was provided directly by the caller. We don't support alternate intents + // in this case, but we still permit refinement of the intent we'll dispatch; e.g., + // clients may use this hook to defer the computation of "lazy" extras in their share + // payload. Note this accommodation isn't strictly "necessary" because clients could + // always implement equivalent behavior by pointing custom targets back at their own app + // for any amount of further refinement/modification outside of the Sharesheet flow; + // nevertheless, it's offered as a convenience for clients who may expect their normal + // refinement logic to apply equally in the case of these "special targets." + results.add(fallbackSourceIntent); } - return results; // TODO: just use our own intent if there's no sourceInfo? + return results; } private static ComponentName getResolvedComponentName( |