summaryrefslogtreecommitdiffstats
path: root/emailcommon
diff options
context:
space:
mode:
authorTony Mantler <nicoya@google.com>2013-09-25 14:47:13 -0700
committerTony Mantler <nicoya@google.com>2013-09-26 13:41:09 -0700
commit463584d23f747cfbbd9856b39390269342363b41 (patch)
tree8288fa41829fa5deaf9789f08055a8a5ba9ce8e9 /emailcommon
parentfeb2c387b0332a28f1dc5e82205ed087277dff92 (diff)
downloadandroid_packages_apps_Email-463584d23f747cfbbd9856b39390269342363b41.tar.gz
android_packages_apps_Email-463584d23f747cfbbd9856b39390269342363b41.tar.bz2
android_packages_apps_Email-463584d23f747cfbbd9856b39390269342363b41.zip
Fix account matching at initial screen to match against email address
b/10210901 Change-Id: I64d60ca33a42a19e085dd98a7a61d68ac30027f9
Diffstat (limited to 'emailcommon')
-rw-r--r--emailcommon/src/com/android/emailcommon/utility/Utility.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/emailcommon/src/com/android/emailcommon/utility/Utility.java b/emailcommon/src/com/android/emailcommon/utility/Utility.java
index e8259bd64..5bdcd11df 100644
--- a/emailcommon/src/com/android/emailcommon/utility/Utility.java
+++ b/emailcommon/src/com/android/emailcommon/utility/Utility.java
@@ -278,6 +278,46 @@ public class Utility {
}
/**
+ * This only actually matches against the email address. It's technically kosher to allow the
+ * same address across different account types, but that's a pretty rare use case and isn't well
+ * handled in the UI.
+ *
+ * @param context context
+ * @param syncAuthority the account manager type to check against or null for all types
+ * @param address email address to match against
+ * @return account name for match found or null
+ */
+ public static String findExistingAccount(final Context context, final String syncAuthority,
+ final String address) {
+ final ContentResolver resolver = context.getContentResolver();
+ final Cursor c = resolver.query(Account.CONTENT_URI, Account.CONTENT_PROJECTION,
+ AccountColumns.EMAIL_ADDRESS + "=?", new String[] {address}, null);
+ try {
+ if (!c.moveToFirst()) {
+ return null;
+ }
+ return c.getString(c.getColumnIndex(Account.DISPLAY_NAME));
+ /*
+ do {
+ if (syncAuthority != null) {
+ // TODO: actually compare the sync authority to allow creating the same account
+ // on different protocols. Sadly this code can't directly access the service info
+ } else {
+ final Account account = new Account();
+ account.restore(c);
+ return account.mDisplayName;
+ }
+ } while (c.moveToNext());
+ */
+ } finally {
+ c.close();
+ }
+ /*
+ return null;
+ */
+ }
+
+ /**
* Generate a random message-id header for locally-generated messages.
*/
public static String generateMessageId() {