thunderbird-android icon indicating copy to clipboard operation
thunderbird-android copied to clipboard

Use remote contact directories (global address list; GAL) for recipient auto-complete

Open doctorjei opened this issue 1 year ago • 6 comments

Checklist

  • [X] I have used the search function to see if someone else has already submitted the same bug report.
  • [X] I will describe the problem with as much detail as possible.

App version

6.804

Where did you get the app from?

Google Play

Android version

12

Device model

Pixel 3a

Steps to reproduce

  1. Add an exchange account to GMail
  2. in contacts app, select new exchange account (upper right corner)
  3. Search for a contact not in the local account list, but in the Exchange GAL (to verify it exists)
  4. In K9, compose new email
  5. Touch three dots in upper right corner to open menu
  6. Select "add from contacts"
  7. Search for same contact previously searched in contacts app

Expected behavior

The contact from the GAL should appear

Actual behavior

The contact from the GAL is not found

Additional Info

Please note that this is not requesting AES or AWS support - just for K9 to look at existing contacts.

This may be due to K9 defaulting to the "main" contact account (as there doesn't appear to be any way to change the account to search from). So, it may actually be a feature request - but there is no indication of which account (if any) is being used to pull contacts.

doctorjei avatar Jul 02 '24 23:07 doctorjei

The "Add from contacts" menu option opens the contacts app to select a contact. If that doesn't show the "GAL contacts", that's an issue with the contacts app, not K-9 Mail.

cketti avatar Jul 15 '24 17:07 cketti

But it does show up in the contacts app when directly directly invoked; that's the issue.

I suppose it's possible that there is no way for another application to open the more general dialog or the Contacts app. I'll try to investigate that and follow up.

doctorjei avatar Jul 15 '24 18:07 doctorjei

I have confirmed that from the Android phone app (Pixel 3a, Android 10), search also searches from other accounts (not just the primary / default), including directories. Here's how I get that result:

  1. Touch the "contacts" tab on the bottom right
  2. search for a contact only in the directory (GAL for Exchange)
  3. The contact appears

I will continue digging, but this does show at least that other applications can get to this data.

doctorjei avatar Jul 15 '24 19:07 doctorjei

@cketti According to https://developer.android.com/reference/android/provider/ContactsContract.Directory: "Access to Contacts Provider is protected by the READ_CONTACTS permission, but access to the directory provider is protected by BIND_DIRECTORY_SEARCH."

K9Mail only requests READ_CONTACTS, so this is clearly not a problem of the contact provider but K9Mail. I experience the same problem with our Google Workspace Directory. Problem is, all our employees are in the GAL only, if I wish to use K9Mail autocomplete I have to copy a contact from the Directory to my private contacts first. Other Android apps seem to support this feature generally, i.e. Samsung and Google dialer apps search in the Directory automatically.

user12921 avatar Aug 20 '24 17:08 user12921

Apparently, Google Workspace contacts (and presumably contacts from other such directories) are not treated like regular contacts on Android. See e.g. https://support.google.com/a/users/answer/7559344?hl=en

Some digging around revealed that Email.CONTENT_FILTER_URI can be used with a DIRECTORY_PARAM_KEY parameter to search a specific directory. Notably, also company directories that are not searched by default.

For an example see https://github.com/klinker41/android-chips/blob/81d0719c80b7aa214b8b7191f31e320e5be8b2b8/library/src/main/java/com/android/ex/chips/BaseRecipientAdapter.java#L943-L944

So K-9 Mail not searching company contact directories is not a bug, but a missing feature.


According to https://developer.android.com/reference/android/provider/ContactsContract.Directory: "Access to Contacts Provider is protected by the READ_CONTACTS permission, but access to the directory provider is protected by BIND_DIRECTORY_SEARCH."

The same page also contains this:

Clients should send directory requests to Contacts Provider and let it forward them to the respective providers rather than constructing directory provider URIs by themselves.

Accessing the list of directories and searching directories via the method described above doesn't need a permission other than READ_CONTACTS. I had a quick look and the Gmail app for example doesn't use the BIND_DIRECTORY_SEARCH permission.

cketti avatar Aug 21 '24 09:08 cketti

Indeed, thats interesting. I just checked the Lineage dialer, which can access the Google directory, but also does not request BIND_DIRECTORY_SEARCH.

This might be helpful: https://github.com/LineageOS/android_packages_apps_Dialer/blob/lineage-21.0/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java

In queryCp2ForExtendedDirectoryIds they seem to load all available directory ids first, before doing a lookup. I had wondered how you would decide which directory to query.

user12921 avatar Aug 21 '24 16:08 user12921