Catch CCE when migrating to ClipData.

Bug: 6231948
Change-Id: I51bc272d29a17881b3d4908fda549da20aa7e6b3
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index d0d9bd6..b4669a7 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -6588,59 +6588,57 @@
 
         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);
-            }
         }
     }