Add a provider call to get device friendly name.

For now, it sends the device model name as friendly name, in lieu
of actually having a user-supplied friendly name. This is wrong
for at least two reasons:

1) We need to have an actual user-supplied friendly name, but that's
   not easy to find.
2) This really shouldn't be a provider query -- it should be something
   the Exchange can know locally (ideally this is a system preference
   but that's not currently implemented). This workaround just lets
   us have some reasonable value that we can update easily.

Bug: 11161234
Change-Id: If83ad768736de19c9d0e833d1f86a6ce9daf5039
diff --git a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
index 4e15e3e..f7b8d72 100755
--- a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
+++ b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
@@ -130,6 +130,13 @@
     public static Uri MAILBOX_MOST_RECENT_MESSAGE_URI;
     public static Uri ACCOUNT_CHECK_URI;
 
+    /**
+     * String for both the EmailProvider call, and the key for the value in the response.
+     * TODO: Eventually this ought to be a device property, not defined by the app.
+     */
+    public static String DEVICE_FRIENDLY_NAME = "deviceFriendlyName";
+
+
     public static String PROVIDER_PERMISSION;
 
     public static synchronized void init(Context context) {
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index e03e4c1..ebdbba5 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -44,6 +44,7 @@
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Binder;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Handler.Callback;
@@ -1943,6 +1944,15 @@
     public Bundle call(String method, String arg, Bundle extras) {
         LogUtils.d(TAG, "EmailProvider#call(%s, %s)", method, arg);
 
+        // Handle queries for the device friendly name.
+        // TODO: This should eventually be a device property, not defined by the app.
+        if (TextUtils.equals(method, EmailContent.DEVICE_FRIENDLY_NAME)) {
+            final Bundle bundle = new Bundle(1);
+            // TODO: For now, just use the model name since we don't yet have a user-supplied name.
+            bundle.putString(EmailContent.DEVICE_FRIENDLY_NAME, Build.MODEL);
+            return bundle;
+        }
+
         // Handle sync status callbacks.
         if (TextUtils.equals(method, SYNC_STATUS_CALLBACK_METHOD)) {
             updateSyncStatus(extras);