Remove setData from clipboard intents

Some apps interpret the "data" field as "to". We're already putting
the URI for share intents in EXTRA_STREAM, so remove it from setData.

Bug: 285871401
Test: manual (share a copied image from personal profile to a work
profile app)

Change-Id: Ic50605799b6ce561674e79696090f0e7b8df03dc
This commit is contained in:
Miranda Kephart
2023-06-20 13:17:15 -04:00
parent f312e919f8
commit 9a35ddf5f8

View File

@@ -42,8 +42,8 @@ class IntentCreator {
// "If using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it should be the
// MIME type of the data in EXTRA_STREAM"
if (clipData.getItemAt(0).getUri() != null) {
shareIntent.setDataAndType(
clipData.getItemAt(0).getUri(), clipData.getDescription().getMimeType(0));
// We don't use setData here because some apps interpret this as "to:".
shareIntent.setType(clipData.getDescription().getMimeType(0));
shareIntent.putExtra(Intent.EXTRA_STREAM, clipData.getItemAt(0).getUri());
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {