Populate device friendly name, if it's available.

Long term we shouldn't need to read it from the EmailProvider
but this allows us to easily update how it works for now.

Bug: 11161234
Change-Id: Ifcc8aa84258f17dd3648a5f897f78ee441e24422
diff --git a/src/com/android/exchange/eas/EasOperation.java b/src/com/android/exchange/eas/EasOperation.java
index 7acbcdd..37b7ead 100644
--- a/src/com/android/exchange/eas/EasOperation.java
+++ b/src/com/android/exchange/eas/EasOperation.java
@@ -516,8 +516,16 @@
         if (deviceId != null) {
             s.data(Tags.SETTINGS_IMEI, tm.getDeviceId());
         }
-        // TODO: What should we use for friendly name?
-        //s.data(Tags.SETTINGS_FRIENDLY_NAME, "Friendly Name");
+        // Set the device friendly name, if we have one.
+        // TODO: Longer term, this should be done without a provider call.
+        final Bundle bundle = mContext.getContentResolver().call(
+                EmailContent.CONTENT_URI, EmailContent.DEVICE_FRIENDLY_NAME, null, null);
+        if (bundle != null) {
+            final String friendlyName = bundle.getString(EmailContent.DEVICE_FRIENDLY_NAME);
+            if (!TextUtils.isEmpty(friendlyName)) {
+                s.data(Tags.SETTINGS_FRIENDLY_NAME, friendlyName);
+            }
+        }
         s.data(Tags.SETTINGS_OS, "Android " + Build.VERSION.RELEASE);
         if (phoneNumber != null) {
             s.data(Tags.SETTINGS_PHONE_NUMBER, phoneNumber);