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
This commit is contained in:
Yu Ping Hu 2013-10-29 19:34:17 -07:00
parent 3e8e59798b
commit 5181cd6d4a
2 changed files with 17 additions and 0 deletions

View File

@ -130,6 +130,13 @@ public abstract class EmailContent {
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) {

View File

@ -44,6 +44,7 @@ import android.database.sqlite.SQLiteException;
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 class EmailProvider extends ContentProvider {
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);