Populate real name in From: field

b/11246653

Change-Id: I8629ba655b99629f7b14f857acb67cb8453ddb8b
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index a9bdbff..4dada5e 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -2376,6 +2376,8 @@
                     .add(UIProvider.AccountColumns.NAME, AccountColumns.DISPLAY_NAME)
                     .add(UIProvider.AccountColumns.ACCOUNT_MANAGER_NAME,
                             AccountColumns.EMAIL_ADDRESS)
+                    .add(UIProvider.AccountColumns.SENDER_NAME,
+                            AccountColumns.SENDER_NAME)
                     .add(UIProvider.AccountColumns.UNDO_URI,
                             ("'content://" + EmailContent.AUTHORITY + "/uiundo'"))
                     .add(UIProvider.AccountColumns.URI, uriWithId("uiaccount"))
@@ -4282,14 +4284,19 @@
      *     - UIProvider.MessageColumns.SNIPPET
      *     - UIProvider.MessageColumns.REPLY_TO
      *     - UIProvider.MessageColumns.FROM
-     *     - UIProvider.MessageColumns.CUSTOM_FROM_ADDRESS
      */
     private Uri uiSaveMessage(Message msg, Mailbox mailbox, Bundle extras) {
         final Context context = getContext();
         // Fill in the message
         final Account account = Account.restoreAccountWithId(context, mailbox.mAccountKey);
         if (account == null) return null;
-        msg.mFrom = account.mEmailAddress;
+        final String customFromAddress =
+                extras.getString(UIProvider.MessageColumns.CUSTOM_FROM_ADDRESS);
+        if (!TextUtils.isEmpty(customFromAddress)) {
+            msg.mFrom = customFromAddress;
+        } else {
+            msg.mFrom = account.getEmailAddress();
+        }
         msg.mTimeStamp = System.currentTimeMillis();
         msg.mTo = extras.getString(UIProvider.MessageColumns.TO);
         msg.mCc = extras.getString(UIProvider.MessageColumns.CC);