diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index d0d9bd6c5e303..b4669a78951f4 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -6588,59 +6588,57 @@ public class Intent implements Parcelable, Cloneable { final String action = getAction(); if (ACTION_SEND.equals(action)) { - Uri stream = null; try { - stream = getParcelableExtra(EXTRA_STREAM); + final Uri stream = getParcelableExtra(EXTRA_STREAM); + final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); + final String htmlText = getStringExtra(EXTRA_HTML_TEXT); + if (stream != null || text != null || htmlText != null) { + final ClipData clipData = new ClipData( + null, new String[] { getType() }, + new ClipData.Item(text, htmlText, null, stream)); + setClipData(clipData); + addFlags(FLAG_GRANT_READ_URI_PERMISSION); + } } catch (ClassCastException e) { } - final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); - final String htmlText = getStringExtra(EXTRA_HTML_TEXT); - if (stream != null || text != null || htmlText != null) { - final ClipData clipData = new ClipData( - null, new String[] { getType() }, - new ClipData.Item(text, htmlText, null, stream)); - setClipData(clipData); - addFlags(FLAG_GRANT_READ_URI_PERMISSION); - } } else if (ACTION_SEND_MULTIPLE.equals(action)) { - ArrayList streams = null; try { - streams = getParcelableArrayListExtra(EXTRA_STREAM); + final ArrayList streams = getParcelableArrayListExtra(EXTRA_STREAM); + final ArrayList texts = getCharSequenceArrayListExtra(EXTRA_TEXT); + final ArrayList htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); + int num = -1; + if (streams != null) { + num = streams.size(); + } + if (texts != null) { + if (num >= 0 && num != texts.size()) { + // Wha...! F- you. + return; + } + num = texts.size(); + } + if (htmlTexts != null) { + if (num >= 0 && num != htmlTexts.size()) { + // Wha...! F- you. + return; + } + num = htmlTexts.size(); + } + if (num > 0) { + final ClipData clipData = new ClipData( + null, new String[] { getType() }, + makeClipItem(streams, texts, htmlTexts, 0)); + + for (int i = 1; i < num; i++) { + clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); + } + + setClipData(clipData); + addFlags(FLAG_GRANT_READ_URI_PERMISSION); + } } catch (ClassCastException e) { } - final ArrayList texts = getCharSequenceArrayListExtra(EXTRA_TEXT); - final ArrayList htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); - int num = -1; - if (streams != null) { - num = streams.size(); - } - if (texts != null) { - if (num >= 0 && num != texts.size()) { - // Wha...! F- you. - return; - } - num = texts.size(); - } - if (htmlTexts != null) { - if (num >= 0 && num != htmlTexts.size()) { - // Wha...! F- you. - return; - } - num = htmlTexts.size(); - } - if (num > 0) { - final ClipData clipData = new ClipData( - null, new String[] { getType() }, - makeClipItem(streams, texts, htmlTexts, 0)); - - for (int i = 1; i < num; i++) { - clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); - } - - setClipData(clipData); - addFlags(FLAG_GRANT_READ_URI_PERMISSION); - } } }