diff options
author | Tony Mantler <nicoya@google.com> | 2014-03-14 15:48:10 -0700 |
---|---|---|
committer | Tony Mantler <nicoya@google.com> | 2014-03-14 15:48:10 -0700 |
commit | 53b64eee54cdb74dc325089b8362a6ff4811759e (patch) | |
tree | 31fbd1570aad804d6436fc56dc5ab911bca23a22 /src/com/android/email/service | |
parent | 282edb95a35d270ed599858b2a342e33599bdeea (diff) | |
download | android_packages_apps_Email-53b64eee54cdb74dc325089b8362a6ff4811759e.tar.gz android_packages_apps_Email-53b64eee54cdb74dc325089b8362a6ff4811759e.tar.bz2 android_packages_apps_Email-53b64eee54cdb74dc325089b8362a6ff4811759e.zip |
Skip protocol choice if user entered from system account manager
b/13475223
Change-Id: Id1ec6259e2b3880f9ce83ffe7795c40aa069466e
Diffstat (limited to 'src/com/android/email/service')
-rw-r--r-- | src/com/android/email/service/EmailServiceUtils.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java index 488e0be10..f24c3804d 100644 --- a/src/com/android/email/service/EmailServiceUtils.java +++ b/src/com/android/email/service/EmailServiceUtils.java @@ -44,6 +44,7 @@ import android.provider.CalendarContract.SyncState; import android.provider.ContactsContract; import android.provider.ContactsContract.RawContacts; import android.provider.SyncStateContract; +import android.text.TextUtils; import com.android.email.R; import com.android.emailcommon.Api; @@ -616,6 +617,28 @@ public class EmailServiceUtils { } } + /** + * Resolves a service name into a protocol name, or null if ambiguous + * @param context for loading service map + * @param accountType sync adapter service name + * @return protocol name or null + */ + public static String getProtocolFromAccountType(final Context context, + final String accountType) { + final Map <String, EmailServiceInfo> serviceInfoMap = getServiceMap(context); + String protocol = null; + for (final EmailServiceInfo info : serviceInfoMap.values()) { + if (TextUtils.equals(accountType, info.accountType)) { + if (!TextUtils.isEmpty(protocol) && !TextUtils.equals(protocol, info.protocol)) { + // More than one protocol matches + return null; + } + protocol = info.protocol; + } + } + return protocol; + } + private static Uri asCalendarSyncAdapter(Uri uri, String account, String accountType) { return uri.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true") .appendQueryParameter(Calendars.ACCOUNT_NAME, account) |