Merge "Catch CCE when migrating to ClipData." into jb-dev

This commit is contained in:
Jeff Sharkey
2012-05-01 16:32:38 -07:00
committed by Android (Google) Code Review

View File

@@ -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<Uri> streams = null;
try {
streams = getParcelableArrayListExtra(EXTRA_STREAM);
final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
final ArrayList<String> 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<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
final ArrayList<String> 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);
}
}
}