Merge cherrypicks of [3661626, 3661980, 3662429, 3661545, 3661546, 3661579, 3661580, 3662430, 3661547, 3661548, 3661549, 3661550, 3662578, 3662579, 3662580, 3662581, 3662582, 3662583, 3661597, 3661598, 3661551, 3661552, 3661553, 3661554, 3661555, 3662596, 3662597, 3662598, 3662599, 3662584, 3662585, 3662586, 3662616, 3662617, 3662618] into oc-m4-release

Change-Id: I3732cba98d2ed2ef54eb3179a65ff077a29c71ac
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index 738111f..3dd9e87 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -1924,6 +1924,15 @@
     }
 
     /**
+     * @return the authority of EmailAttachmentProvider for this app. should be overridden in
+     * concrete app implementations. can't be known here because this project doesn't know about
+     * that sort of thing.
+     */
+    protected String getEmailAttachmentProviderAuthority() {
+        throw new UnsupportedOperationException("unimplemented, EmailAttachmentProvider unknown");
+    }
+
+    /**
      * Helper function to handle a list of uris to attach.
      * @return true if anything has been attached.
      */
@@ -1944,7 +1953,9 @@
                         }
                     } else if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
                         // disallow attachments from our own EmailProvider (b/27308057)
-                        if (getEmailProviderAuthority().equals(uri.getAuthority())) {
+                        if (getEmailProviderAuthority().equals(uri.getAuthority())
+                                || getEmailAttachmentProviderAuthority().equals(
+                                        uri.getAuthority())) {
                             showErrorToast(getString(R.string.attachment_permission_denied));
                             Analytics.getInstance().sendEvent(ANALYTICS_CATEGORY_ERRORS,
                                     "send_intent_attachment", "email_provider", 0);