Show an error on security exception for attachments.
This uses an existing notification for bad forwarding. The
text is a bit odd ("Attachment not forwarded") but avoids
adding new text right now, and at least conveys the error.
Bug: 8417004
Change-Id: Id3629a39b2afb583bac2ea6a3ef1303694f1100c
diff --git a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java
index 51a62fd..f8bc9cc 100644
--- a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java
+++ b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java
@@ -260,6 +260,7 @@
writeBoundary(writer, multipartBoundary, false);
Attachment attachment =
Attachment.getContent(attachmentsCursor, Attachment.class);
+ attachment.mAccountKey = message.mAccountKey;
writeOneAttachment(context, writer, stream, attachment);
writer.write("\r\n");
} while (attachmentsCursor.moveToNext());
@@ -321,12 +322,13 @@
out.write('\r');
out.write('\n');
out.flush();
- }
- catch (FileNotFoundException fnfe) {
+ } catch (final FileNotFoundException fnfe) {
// Ignore this - empty file is OK
- }
- catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new MessagingException("Invalid attachment.", ioe);
+ } catch (final SecurityException se) {
+ throw new MessagingException(MessagingException.GENERAL_SECURITY,
+ "No permissions for attachment", attachment);
}
}
diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java
index 6a0f1e1..21d9e59 100644
--- a/src/com/android/email/MessagingController.java
+++ b/src/com/android/email/MessagingController.java
@@ -2070,6 +2070,12 @@
nc.showLoginFailedNotification(account.mId);
}
mListeners.sendPendingMessagesFailed(account.mId, messageId, me);
+ if (me.getExceptionType() == MessagingException.GENERAL_SECURITY) {
+ final Object exceptionData = me.getExceptionData();
+ if (exceptionData != null && exceptionData instanceof Attachment) {
+ nc.showDownloadForwardFailedNotification((Attachment) exceptionData);
+ }
+ }
continue;
}
// 5. move to sent, or delete