Fix sharing traces.

Migrating the stream to clipData doesn't happen automatically in Q since
the intent is passed through UserConsentActivityDialog and isn't unparcelled
during that time.

This change manually adds the same stream to clipData so that it can be
successfully attached to emails or other sharing mechanisms.

Bug: 119399115
Test: Manually shared traces to gmail.
Change-Id: Ia9291088c1a65dbf1a8cffd97f21a54191b6a9a4
diff --git a/src/com/google/android/traceur/FileSender.java b/src/com/google/android/traceur/FileSender.java
index 49eb0ce..220ec37 100644
--- a/src/com/google/android/traceur/FileSender.java
+++ b/src/com/google/android/traceur/FileSender.java
@@ -21,6 +21,7 @@
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.content.ClipData;
 import android.content.Context;
 import android.support.v4.content.FileProvider;
 import android.content.Intent;
@@ -36,6 +37,7 @@
 public class FileSender {
 
     private static final String AUTHORITY = "com.android.traceur.files";
+    private static final String MIME_TYPE = "application/vnd.android.systrace";
 
     public static void postNotification(Context context, File file) {
         // Files are kept on private storage, so turn into Uris that we can
@@ -88,15 +90,21 @@
      * Build {@link Intent} that can be used to share the given bugreport.
      */
     private static Intent buildSendIntent(Context context, Uri traceUri) {
+        final CharSequence description = SystemProperties.get("ro.build.description");
+
         final Intent intent = new Intent(Intent.ACTION_SEND);
         intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         intent.addCategory(Intent.CATEGORY_DEFAULT);
-        intent.setType("application/vnd.android.systrace");
+        intent.setType(MIME_TYPE);
 
         intent.putExtra(Intent.EXTRA_SUBJECT, traceUri.getLastPathSegment());
-        intent.putExtra(Intent.EXTRA_TEXT, SystemProperties.get("ro.build.description"));
+        intent.putExtra(Intent.EXTRA_TEXT, description);
         intent.putExtra(Intent.EXTRA_STREAM, traceUri);
 
+        // Explicitly set the clip data; see b/119399115
+        intent.setClipData(new ClipData(null, new String[] { MIME_TYPE },
+            new ClipData.Item(description, null, traceUri)));
+
         final Account sendToAccount = findSendToAccount(context);
         if (sendToAccount != null) {
             intent.putExtra(Intent.EXTRA_EMAIL, new String[] { sendToAccount.name });