Add FLAG_GRANT_READ_URI_PERMISSION to contact share intent#25
Open
essentialols wants to merge 2 commits intoGrapheneOS:16-qpr2from
Open
Add FLAG_GRANT_READ_URI_PERMISSION to contact share intent#25essentialols wants to merge 2 commits intoGrapheneOS:16-qpr2from
essentialols wants to merge 2 commits intoGrapheneOS:16-qpr2from
Conversation
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.
cd57fa1 to
cd9601b
Compare
Author
|
Updated: The fix now covers all three contact share paths (not just single-contact share), and explicitly sets
The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FLAG_GRANT_READ_URI_PERMISSIONto the share intent inshareContact()so that receiving apps can read the vCard data without needingREAD_CONTACTSpermissionProblem
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 lackREAD_CONTACTSpermission (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 holdsREAD_CONTACTSpermission.While
Intent.createChooser()is supposed to propagate URI permissions viaClipData, 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