Skip to content

Add FLAG_GRANT_READ_URI_PERMISSION to contact share intent#25

Open
essentialols wants to merge 2 commits intoGrapheneOS:16-qpr2from
essentialols:fix/share-contact-uri-permission
Open

Add FLAG_GRANT_READ_URI_PERMISSION to contact share intent#25
essentialols wants to merge 2 commits intoGrapheneOS:16-qpr2from
essentialols:fix/share-contact-uri-permission

Conversation

@essentialols
Copy link
Copy Markdown

Summary

  • Adds FLAG_GRANT_READ_URI_PERMISSION to the share intent in shareContact() so that receiving apps can read the vCard data without needing READ_CONTACTS permission

Problem

When sharing a contact via the share menu, the intent carries a content://com.android.contacts/contacts/as_vcard/ URI but does not explicitly grant read permission to the receiving app. Apps that lack READ_CONTACTS permission (such as Signal, which many GrapheneOS users configure with limited permissions or Contact Scopes) cannot read the vCard data from the content provider URI. This causes the receiving app to report the shared file as invalid.

Sharing via SMS/MMS works fine because those apps typically have broader permissions or handle the URI differently.

Fix

One-line addition of intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) before the chooser is created. This grants the receiving app temporary read access to the specific vCard URI, regardless of whether it holds READ_CONTACTS permission.

While Intent.createChooser() is supposed to propagate URI permissions via ClipData, this does not reliably work for all URI schemes and permission configurations, particularly with GrapheneOS's Contact Scopes feature. The explicit flag ensures correct behavior.

Related

When sharing contacts via the share menu, the intents carry
content://com.android.contacts/ URIs but do not grant read permission
or set ClipData. Receiving apps that lack READ_CONTACTS permission
(such as Signal on GrapheneOS with Contact Scopes) cannot read the
vCard data, causing them to report the shared file as invalid.

Add ClipData and FLAG_GRANT_READ_URI_PERMISSION to all three share
paths:
- Single contact share (QuickContactActivity.shareContact)
- Multi-contact share (DefaultContactBrowseListFragment)
- Favorite contacts share (ExportDialogFragment)

Setting ClipData explicitly is necessary because Intent.createChooser()
propagates URI grants via ClipData, not EXTRA_STREAM. Without ClipData,
the grant flag alone may not reach the target app reliably through the
chooser.
@essentialols essentialols force-pushed the fix/share-contact-uri-permission branch from cd57fa1 to cd9601b Compare February 21, 2026 19:00
@essentialols
Copy link
Copy Markdown
Author

Updated: The fix now covers all three contact share paths (not just single-contact share), and explicitly sets ClipData in addition to FLAG_GRANT_READ_URI_PERMISSION.

Intent.createChooser() propagates URI grants via ClipData, not EXTRA_STREAM, so the flag alone was insufficient. The three paths fixed:

  1. QuickContactActivity.shareContact() - single contact
  2. DefaultContactBrowseListFragment.shareSelectedContacts() - multi-contact
  3. ExportDialogFragment.doShareFavoriteContacts() - favorites

The ExportProcessor file-based export path already handles this correctly via FileProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant