Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Run CI for #12649 #12696

Closed
wants to merge 1 commit into from
Closed

Conversation

Mugurell
Copy link
Contributor

@Mugurell Mugurell commented Aug 26, 2022

Run CI for #12649

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

GitHub Automation

Fixes #12689
Fixes #12

Image sharing currently only works when sharing to an app but not when
using the Android Direct Share feature, where it fails with a
SecurityException.

"Direct Share" is what Android calls the app created shortcuts,
i.e. individual chats from a messaging application.

The code pretty much already does the right thing (i.e. setting
the FLAG_GRANT_READ_URI_PERMISSION on the target intent as well as the
Chooser action, as described in ACTION_CHOOSE Api docs[1]) but there's
some platform internals that seem to go wrong here but we can work
around it with this patch.

https://issuetracker.google.com/issues/151386328 describes a similar
Problem, especially mozilla-mobile#12 in there offers a similar workaround and an
explanation:

  The underlying problem is that ACTION_SEND is using EXTRA_STREAM for the
  content URI. But the FLAG_GRANT_*_URI_PERMISSION mechanism only works
  with URIs in Intent.data and Intent.clipData. The framework contains
  some code that tries to work around this limitation. But it doesn't
  handle this particular case. Intent.createChooser() migrates the flags
  and data/clipData from the target Intent, but it does so before the
  framework had a chance to fix up the target Intent via Intent.migrateExtraStreamToClipData().

And indeed moving the clipData into the inner intent makes Direct Share
work and preserves the image preview in the Intent.

[1] file:///<SDK-DIR>/docs/reference/android/content/Intent.html#ACTION_CHOOSER
  If you need to grant URI permissions through a chooser, you must specify
  the permissions to be granted on the ACTION_CHOOSER Intent in addition to
  the EXTRA_INTENT inside. This means using setClipData(ClipData) to
  specify the URIs to be granted as well as FLAG_GRANT_READ_URI_PERMISSION
  and/or FLAG_GRANT_WRITE_URI_PERMISSION as appropriate.
@mergify
Copy link
Contributor

mergify bot commented Aug 26, 2022

⚠️ The sha of the head commit of this PR conflicts with #12649. Mergify cannot evaluate rules on this PR. ⚠️

@Mugurell
Copy link
Contributor Author

Original PR landed. Closing this.

@Mugurell Mugurell closed this Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot share images using Direct Share Setup continous integration and deployment
2 participants